Monday, 7 January 2019

AngularJS ng-bind directive


AngularJS ng-bind directive

ng-bind directive use to bind the innerHTML of the element to the model property. if any changes happen , it will reflect the changes in innerHTML of the element.
it can be used as attribute or as css class

Syntax ng-bind as CSS class
<element class="ng-bind: expression"></element>

Syntax ng-bind as attribute
<element ng-bind="expression"></element>

Example: As CSS class
<div ng-app="myApp" ng-controller="EmployeeController">
    <p>Example: As CSS class</p>
    <br />
    Name: <input type="text" ng-model="Name" />
    <p class="ng-bind:Name"></p>
</div>

<script>
    var myapp = angular.module('myApp', []);
    myapp.controller('EmployeeController', function ($scope) {
        $scope.Name = "www.code-view.com";
    });
</script>

Output:-


No comments:

Post a Comment