I want to take data from ng-bind-html and bind it to some other html tags.Though i can directly use ng-bind-html for it. But is there any other way where we can use the binded html to other HTML tags?
JS:
$scope.left = '<span>Hello World</span><strong>New Testing<strong><br/>h1>Testing</h1>';
HTML:
<div ng-bind-html="left" ng-model="GetValues"></div>
<span>{{GetValues}}</span>
html
<div my-directive="left" ng-model="GetValues"></div>
var app = angular.module('myApp',[]);
app.controller('ctrlMain',function($scope){
$scope.bindMe = {id:1,myvar:"test"};
});
app.directive('myDirective', function($compile){
return{
restrict: 'A',
scope: {
varToBind: '=myDirective'
},
link: function(scope, elm, attrs){
outerList = '<span>Hello World</span><strong>New Testing<strong><br/>h1>Testing</h1>';
outerList = $compile(outerList)(scope);
elm.replaceWith(outerList);
}
}
});
you can directly include a html file :)
<div ng-include="'myFile.htm'"></div>//your DOM string code should be in myfile.htm file