AngularJSがよくわからないので備忘のためにメモ。
今回は、$watchで監視している値が0のとき、ボタンを使えなくする。
スクリプト
$scope.inputValue = function() {
var total = 0;
// 0の場合はボタンが押せないようにする
$scope.test = true;
if(total > 0){
$scope.test = false;
}
return total;
}
$scope.$watch($scope.inputValue);
テンプレート
<p>値 {{inputValue()}}</p>
<a class="button" ng-class="{disabled: test}">送信</a>