Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • I think this will work, but how could I connect the two files? I cannot just do ng-controller="ctrl" Commented Oct 26, 2015 at 15:02
  • 1
    $scope.bindHtml =function(){angular.element(document.getElementById('_item')).append($compile("<div> <p>{{item}}</p> </div>")($scope)); }; // call the function in ng-init="bindHtml" in the html page. <div ng-controller="[YOURCONTROLLER NAME]" ng-init="bindHtml()"><section id="_item"></section></div> Commented Oct 26, 2015 at 15:15
  • What is the significance of doing ($scope) at the end?? Commented Sep 18, 2018 at 15:49
  • Dear Bikal Nepal $compile recompile the appended HTML code and apply $scope Commented Mar 18, 2020 at 20:33