The ngBindTemplate directive specifies that the element text content should be replaced with the interpolation of the template in the ngBindTemplate attribute.
Instead of ng-bind, using the ng-bind-template bind more than one expression ( {{… }} ).
This directive is essential hence HTML elements cannot contain span element like TITLE and OPTION.
Syntax for ng-bind-template directive in AngularJS:
Denotes one or more expressions to evaluate, each surrounded by { { } }.
Sample coding for ng-bind-template directive in AngularJS:
Code Explanation for ng-bind-template directive in AngularJS:
The ng-app specifies the root element (“myApp”) to define AngularJS application.
ng-controller specifies the application controller in AngularJS the controller value is given as “templateCtrl”.
The ng-bind-template is used to bind the AngularJS values in the format of multiple expression ( { { firstName}} {{ lastName } } ) to the HTML Document and the output displayed in <p> tag. but the ng-bind directive is not support the multiple expression instead of it can be use the concatenate operator (+).
scope.firstName is used to declare the scope object as “wiki”.
$scope.lastName is used to declare the scope object as “techy”.
Sample Output for ng-bind-template directive in AngularJS:
The output displays the firstName “wiki”.
The output displays the lastName “techy”.
The output displays the concatenation of firstname and lastname (“wikitechy!”) using ng-bind-template.