Note that there are some explanatory texts on larger screens.

plurals
  1. POAngularJS not getting activated when loading HTML from script
    primarykey
    data
    text
    <p>I have this scenario, I am loading part of HTML (which has AngularJS directives) dynamically via script and I see AngularJS is not getting activated.</p> <p>here is the example I am looking at. Is there anyway I can tell AngularJS to start bind on document ready? Loading an aspx page containing this widget1 content via a iframe seems to work but I am trying to avoid iframe and use client side script. Appreciate any help.</p> <pre><code>&lt;body ng-app&gt; main content page &lt;br /&gt; &lt;!-- widget1 --&gt; &lt;b&gt;Widget1&lt;/b&gt; &lt;div id="widget1"&gt; &lt;!-- load below div via jquery/or any method from a remote html file--&gt; &lt;script type="text/javascript"&gt; $("div#widget1").load("/widgetsfolder/widget1.htm"); &lt;/script&gt; &lt;/div&gt; </code></pre> <p></p> <p>widget.htm file has below content.</p> <pre><code> &lt;div ng-controller="TodoCtrl"&gt; Total todo items: {{getTotalItems()}} &lt;ul class="unstyled"&gt; &lt;li ng-repeat="todo in todos"&gt; &lt;input type="checkbox" ng-model="todo.done" /&gt; &lt;span class="done-{{todo.done}}"&gt;{{todo.text}} &lt;/span&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>my controller code below.</p> <p><pre><code>`function TodoCtrl($scope) { $scope.totalItems = 4; debugger; $scope.todos = [{ text: 'learn angularjs', done: false }, { text: 'implement angularjs', done: false }, { text: 'something else', done: false }, ];</p> $scope.getTotalItems = function () { return $scope.todos.length; } </code></pre> <p>}`</p> <p>sample code here <a href="http://jsfiddle.net/devs/RGfp4/" rel="nofollow">http://jsfiddle.net/devs/RGfp4/</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload