アプリ内のすべての要素の非表示と表示の式を確認したいと思います。
引数を返すだけの関数で show ディレクティブをラップすることで、それができることはわかっています。
<div ng-show="catchShow(myShowExpr == 42)"></div>
ただし、アプリのすべての入力ですべての非表示/表示を監視したいのですが、上記では十分ではありません。
ngShow
/ngHide
ディレクティブをオーバーロードすることもできますが、式を再評価する必要があります。
非常に単純なので、ソースを変更することもできます。
var ngShowDirective = ['$animator', function($animator) {
return function(scope, element, attr) {
var animate = $animator(scope, attr);
scope.$watch(attr.ngShow, function ngShowWatchAction(value) {
var fn = toBoolean(value) ? 'show' : 'hide';
animate[fn](element);
//I could add this:
element.trigger(fn);
});
};
}];
その後、Google CDNを使用できませんでした...
誰もがこれを行うために考えられるより良い方法はありますか?