2016-08-17 10 views

答えて

0

ここでは、チェックボックスののStateChangeを見て、それが変化したときに何かをすることができる方法のPlunkrの例です:

https://plnkr.co/edit/kyEv7IyAXGFRdZjaD4vM?p=preview

var app = angular.module('plunker', []); 

    app.controller('MainCtrl', function($scope) { 
    $scope.$watch("testCheckBox", function(newVal, oldVal){ 
     alert('Checkbox changed!') 
    }); 

}); 

HTML:HTMLにいくつかのコードが欠け

<body ng-controller="MainCtrl"> 
<p>Check box test</p> 
<input type="checkbox" name="testCheckbox" ng-model="testCheckBox"></input> 

</body> 
+0

お返事ありがとうございます。 – Bharath

+0

しかし、チェックボックスはng-repeat内に作成されます。 – Bharath

+0

私は別の名前を付けることはできません。 – Bharath