0

For Example in asp.net with c# we build string like

string str="<div>..in that tag we can use any type of controls..</div>";

we can bind the string as htmlgenericController, so is there any option like above in angularjs?

1 Answer 1

2

Yes it is, there is an example in AngularJS Documentation:

Controller:

angular.module('bindHtmlExample', ['ngSanitize'])
   .controller('ExampleController', ['$scope', function($scope) {
       $scope.myHTML = 'I am an <code>HTML</code>string with ' + '<a href="#">links!</a> and other <em>stuff</em>';
}]);

HTML:

<div ng-controller="ExampleController">
    <p ng-bind-html="myHTML"></p>
</div>

Output:

<div ng-controller="ExampleController">
    <p>I am an <code>HTML</code>string with ' + '<a href="#">links!</a> and other <em>stuff</em></p>
</div>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.