Introduction
In this article we will learn how to bind content To html using angular attributes. Here we learn bind content using ng-bind-html attribute of angular. Direct binding of Angular Text to Html .
Previous Updates
In previous articles we have learnt Read Write connection string from web.config file. EncryptByPassPhrase and DecryptByPassphrase function in Sql Base64 Encoding And Decoding In SQL Server. AngularJS vs JavaScript Example.
Bind Content To Html
We can bind the data to Html page using ng-bind-html Attribute and also with the simple binding without any attribute.
In below example we can see angular attributes like ng-app, ng-controller, ng-bind-html.
Below both bindings are used to display data into Html form. In simple Binding we only use
the {{ }} for define the variable which contains the data.
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular-sanitize.js"></script>
<script>
var app = angular.module("myApp", ['ngSanitize']);
app.controller("DemoAgCtrl", function ($scope) {
$scope.msg = "This is Angular Binding Example.";
});
</script>
</head>
<body>
<div ng-controller="DemoAgCtrl">
<h3>Using Direct Binding </h3> {{msg}}
<h3>Using ng-bind-html Attribute </h3><p ng-bind-html="msg"></p>
</div>
</body>
</html>
|
Output :-
0 comments:
Post a Comment