「スコープ」を使用したバインディングでディレクティブを作成しました。場合によっては、定数オブジェクトをバインドしたいことがあります。たとえば、HTML の場合:
<div ng-controller="Ctrl">
<greeting person="{firstName: 'Bob', lastName: 'Jones'}"></greeting>
</div>
および JavaScript:
var app = angular.module('myApp', []);
app.controller("Ctrl", function($scope) {
});
app.directive("greeting", function () {
return {
restrict: "E",
replace: true,
scope: {
person: "="
},
template:
'<p>Hello {{person.firstName}} {{person.lastName}}</p>'
};
});
これは機能しますが、JavaScript エラーも発生します。
Error: 10 $digest() iterations reached. Aborting!
エラーを発生させずに定数オブジェクトをバインドする正しい方法は何ですか?