Ng-Bind-Html-8

 

In this example, We basically use ng-repeat to iterate on an object items and create links or span label means whatever html you provide. scope object is: $scope.items = [{ html: "

LearnIt

" }, { html: "Link" }]; html side:


See the example below:

 
 
 
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular-sanitize.js"></script> </head> <body ng-app="myApp"> <div ng-controller="myController"> <div ng-repeat="item in items" ng-bind-html="item.html"> </div> </div> <script> var app = angular.module("myApp", ['ngSanitize']); app.controller('myController', ['$scope', function ($scope) { $scope.items = [{ html: "<h2>LearnIt</h2>" }, { html: "<a href='http://learnit.visrosoftware.com/'>Link</a>" }]; }]); </script> </body> </html>
Output