Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Edit: see the other answer I posted.</p> <p>I've gone and implemented blesh's idea in a seperable way. My <code>ngOnce</code> directive just destroys the child scope that <code>ngRepeat</code> creates on each item. This means the scope doesn't get reached from its parents' <code>scope.$digest</code> and the watchers are never executed.</p> <p><a href="http://jsfiddle.net/FsUuH/3/" rel="noreferrer">Source and example on JSFiddle</a></p> <p>The directive itself:</p> <pre class="lang-js prettyprint-override"><code>angular.module('transclude', []) .directive('ngOnce', ['$timeout', function($timeout){ return { restrict: 'EA', priority: 500, transclude: true, template: '&lt;div ng-transclude&gt;&lt;/div&gt;', compile: function (tElement, tAttrs, transclude) { return function postLink(scope, iElement, iAttrs, controller) { $timeout(scope.$destroy.bind(scope), 0); } } }; }]); </code></pre> <p>Using it:</p> <pre class="lang-html prettyprint-override"><code> &lt;li ng-repeat="item in contents" ng-once&gt; {{item.title}}: {{item.text}} &lt;/li&gt; </code></pre> <p><strong>Note</strong> <code>ng-once</code> doesn't create its own scope which means it can affect sibling elements. These all do the same thing:</p> <pre class="lang-html prettyprint-override"><code> &lt;li ng-repeat="item in contents" ng-once&gt; {{item.title}}: {{item.text}} &lt;/li&gt; &lt;li ng-repeat="item in contents"&gt; &lt;ng-once&gt; {{item.title}}: {{item.text}} &lt;/ng-once&gt; &lt;/li&gt; &lt;li ng-repeat="item in contents"&gt; {{item.title}}: {{item.text}} &lt;ng-once&gt;&lt;/ng-once&gt; &lt;/li&gt; </code></pre> <p><strong>Note</strong> <a href="https://github.com/angular/angular.js/issues/2720" rel="noreferrer">this may be a bad idea</a></p>
    singulars
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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