How to bind variables in Angular JS using ng-bind?

By | August 5, 2017

You can use the ng-bind directive, which will bind the innerHTML of the element to the specified model property:

Method 1

	<p ng-bind="demo_var"></p>

Method 2

	<p>First name: {{firstname}}</p>

Complete Example

<!DOCTYPE html>
<script src=""></script>

<div ng-app="myApp" ng-controller="myCtrl">
    <p ng-bind="firstName"></p>
    <p>{{ lastName }}</p>

var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
    $scope.firstName = "Coderz";
    $scope.lastName = "Heaven";    

<p>Use the ng-bind directive to bind the innerHTML of an element to a property in the data model.</p>


Leave a Reply

Your email address will not be published. Required fields are marked *