この単純なコントローラーマークアップがあります
<div ng-controller="TestCtrl" ng-show="isVisible()">
<input type="text" ng-model="smth"/><br>
<span>{{smth}}</span>
</div>
そしてコントローラー自体
function TestCtrl($scope, $log)
{
$scope.smth = 'smth';
$scope.isVisible = function(){
$log.log('isVisible is running');
return true;
}
}
モデルを少し変更するたびに (テキスト ボックス内の 1 文字を変更するなど) isVisible is running
、コンソールに表示されるのはなぜですか? そのような場合は問題ありませんが、応用範囲が広いと思います。これを避けることはできますか?