ng-bind-html

What is ng-bind-html:ng-bind-html used to evaluate/add a HTML content in current HTML page..
Description of ng-bind-html:ng-bind-html evaluate or add a HTML content in given HTML code ,it is useful when we want to ass some external HTML code in our current HTML at run time..
Syntax of ng-bind-html:
<element ng-bind-html-unsafe="expression">

</element>
or


<div ng-bind-html-unsafe="expression"></div>
How to Use ng-bind-html/ng-bind-html Example::
 Example 1:
<div ng-app="webapp">
    <div ng-controller="angularjsexampleCtlr" ng-init="myhtml='<label>This HTML content added outside form this page.</label>'">
        <div>
            Angularjs Example of ng-bind-html
            <div ng-bind-html-unsafe="myhtml"></div>
        </div>
    </div>
</div>

Example 2:
<div ng-app="webapp">
    <div ng-controller="angularjsexampleCtlr" ng-init="mycount=1">
        <div>
            Angularjs Example of ng-bind-html
            <div ng-bind-html-unsafe="myhtml"></div>
        </div>
    </div>
</div>

<script>
    angular.module('webapp', []).controller('angularjsexampleCtlr', function ($scope, $http) {
        $scope.myhtml = '<label>This HTML content added outside form this page.</label>';
    });

</script>

No comments :

Post a Comment