javascript - Angular 1.x: How to execute various action when checkbox is checked and unchecked -
i have html input checkbox field this:
<input type="checkbox" ng-change="itemchecked()"> happy
my amgular 1.x code this:
$scope.itemchecked = function(){ // if checked // eg: have google map , when function called, // loads marker , adds businesses name. // return original state when unchecked // eg: when checked, loads business in google map, // when unchecked, supposed remove marker // points google maps, if page loaded };
i able to:
// if checked
but not able revert original state.
how do that?
fyi: there going multiple checkbox, refreshing page wont work.
add ng-model input , check value in on change function
<input type="checkbox" ng-model="checked" ng-change="itemchecked()"> $scope.itemchecked = function(){ if($scope.checked == true){ // if checked } else{ // return original state } };
Comments
Post a Comment