Angular ng bind directive Example

Angular ng bind directive Example

Today, We want to share with you Angular ng bind directive Example.
In this post we will show you Angular ng bind directive Example, hear for Angular ng bind directive Example we will give you demo and example for implement.
In this post, we will learn about Angular ng bind directive Example with an example.

AngularJs ng-bind directive

The ng-bind directive has one-way data binding ($scope to view). It has a shortcut Example of {{ val }} which displays the scope value any $scope.val inserted into html where val is a variable name here.tHE ng-Bind directive use for display a variable in html SIMPLE page and we can change any variable just from change controller and html just show any variable.

READ :  Angular routeprovider pass multiple parameters

The ng-bind directive is also safer because it represents html as a string value.This ng-bind is a one tyep of directive, it will use The watcher on what is being passed to ng-bind.

ng-bind directive (one-way binding)
ng-bind directive ( bind text content)
ng-bind directive is an alternative to the interpolation directive.

Syntax of ng-bind directive : As a attribute

    <element ng-bind="your expression here"></element>   

Syntax of ng-bind directive : As a Class

    <element  class="ng-bind: your expression here"></element>   

we are not using ng-bind, instead something Like Example : ng-bind is better than {{…}}

<div>
  Hello, {{user.name}}
</div>

Like...

<div>
  Hello, <span ng-bind="user.name"></span>
</div>

The ng-bind directive has its problems too.

use angular filters, limit or something

READ :  AngularJS All Currency Filters formats

AngularJS ng-bind Directive Example

<!DOCTYPE html>
<html>
<head>
    <title>AngularJS ng-bind Directive Example</title>
    <script src="https://infinityknow.com/libs/angular.min.js"></script>
</head>
<body ng-app="infinityknowApp">
	<h1>AngularJS Controller: Example</h1>
    <div ng-controller="simpleCtrl">
        <label>Enter Your Message here: <input type="text" ng-model="ctrlmessage"></label><br>  
  Hello <span ng-bind="ctrlmessage"></span>!  
    </div>
    <script>
        var myngApp = angular.module('infinityknowApp', []);

        myngApp.controller('simpleCtrl', function ($scope) {
            $scope.ctrlmessage = "Wel-come to Hello World! Example with ng-bind directive";        
        });
    </script>
</body>
</html>

AngularJS ng-bind – directive in module ng Example

<!DOCTYPE html>
<html>
<head>
    <title>AngularJS ng-bind - directive in module ng</title>
    <script src="https://infinityknow.com/libs/angular.min.js"></script>
</head>
<div ng-app="" ng-init="scode='Angularjs ng-bind Example SIMPLE code here'">
<p ng-bind="scode"></p>
</div>
</html>

View Demo

Add a Comment

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