Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is because if you use the <code>=</code> type of scope field link, the attribute value is being observed for changes, but tested for reference equality (with <code>!==</code>) rather than tested deeply for equality. Specifying object literal in-line will cause angular to create the new object whenever the atribute is accessed for getting its value — thus when angular does dirty-checking, comparing the old value to the current one always signals the change.</p> <p>One way to overcome that would be to modify angular's source as described here:</p> <p><a href="https://github.com/mgonto/angular.js/commit/09d19353a2ba0de8edcf625aa7a21464be830f02" rel="nofollow">https://github.com/mgonto/angular.js/commit/09d19353a2ba0de8edcf625aa7a21464be830f02</a>.</p> <p>Otherwise, you could create your object in the controller and reference it by name in the element's attribute:</p> <p><strong>HTML</strong></p> <pre><code>&lt;div ng-controller="Ctrl"&gt; &lt;greeting person="personObj"&gt;&lt;/greeting&gt; &lt;/div&gt; </code></pre> <p><strong>JS</strong></p> <pre><code>app.controller("Ctrl", function($scope) { $scope.personObj = { firstName : 'Bob', lastName : 'Jones' }; }); </code></pre> <p>Yet another way is to create the object in the parent element's <code>ng-init</code> directive and later reference it by name (but this one is less readable):</p> <pre><code>&lt;div ng-controller="Ctrl" ng-init="personObj = { firstName : 'Bob', lastName : 'Jones' }"&gt; &lt;greeting person="personObj"&gt;&lt;/greeting&gt; &lt;/div&gt; </code></pre>
    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.
    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