$watch
私はディレクティブにいて、ローカルに存在する変数と に存在する変数で$scope
ユニオンを実行したいと考えてい$rootScope
ます。次のようになります。
myapp.directive('cohnbread',
['TEMPLATE_URL', '$rootScope',
function(TEMPLATE_URL, $rootScope) {
return {
templateUrl: TEMPLATE_URL + "cohnbread.html",
scope: { odp: '@' },
link: function(scope, elem, attrs) {
// here I would like to register a callback to fire
// whenever scope.bar or $rootScope.foo fires. Something like:
$watchBoth('scope.bar', '$rootScope.foo', onBarOrFooChange);
}
};
}]);
これを実現するための回避策はありますか?
より多くの情報を提供するために編集されました。