Monday, 7 January 2019

AngularJS ng-bind-template Directive


AngularJS ng-bind-template Directive

The ng-bind-template directive use to replace the content of the define HTML element with the value of a given expression.
ng-bind-template only runs "strings". ng-bind-template can contain multiple {{ }} expressions.

Syntax:  <element ng-bind-template="expression"></element>

ng-bind-template Example

<div ng-app="myApp1" ng-controller="Employee1Controller">
    <p>First Name: <input type="text" ng-model="firstName" /></p>
    <p>Last Name: <input type="text" ng-model="lastName" /></p>
    <p>Full Name: <span ng-bind-template="{{firstName}} {{lastName}}"></span></p>
</div>

<script>
    var myapp = angular.module('myApp1', []);
    myapp.controller('Employee1Controller', function ($scope) {
        $scope.firstName = "Alok";
        $scope.lastName = "Singh";
    });
</script>

No comments:

Post a Comment