Hardcode html in scope

Description

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

Example


<!--from ww  w. java 2  s . com-->
<!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>

Click to view the demo





















Home »
  AngularJS »
    AngularJS Example »




Controller
Directives
Expression
Filter
Form
Inject
Scope
Server
Style
Template
Utilities