AngularJS Tutorial - Hardcode html in scope








The following code shows how to hardcode html in scope and use a loop to display them.

Example


<!--   ww w . j ava2 s.c o  m-->
<!DOCTYPE html>
<html  ng-app>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
</head>
<body>
<div ng:app="myApp">
<div ng:controller="Tester">
        <div class="boxes">
            <div ng:repeat="item in items">
               {{item.html}}
            </div>
        </div>
</div>
<script type='text/javascript'>
var myApp = angular.module('myApp', []);
function Tester($scope) {
    $scope.items = [{html:"<span>1</span>"},{html:"<h3>some text</h3>"}];
}
</script>
</body>
</html>

The code above is rendered as follows: