Skip to content Skip to sidebar Skip to footer

Parse Html Fragment With Angularjs

I have a part of a screen that is retrieved dynamically through AJAX, and replaces an existing part (think about a paginated grid, that when you click on 'next' you get a new HTML

Solution 1:

you can use $compile for example you have

var htmlText = "<div>{{name}} <select>...</select></div>";

in your directive you can do like this

$scope.compiled= $compile(htmlText)($scope);

To parse a replaced section of the document would be:

var el = angular.element(document.getElementById('#container'));
el.html(ajaxHtml);
$compile(el.contents())(scope);

Post a Comment for "Parse Html Fragment With Angularjs"