It turns out I have a switch from the Angular Bootstrap Toggle library and I need to control its function using ng-change
.
In my html I have the switch as follows:
<toggle ng-model="ValueResponse" ng-change="changed()" on="Enabled" off="Disabled"></toggle> :Movil.
ValueResponse
corresponds to the function that indicates the state of the mobile, that is, if it is active or inactive
Conection.CheckMovil({
sucursal_id: SaveCredentials.getData().id_sucursal
}, function(respuesta) {
var data = JSON.parse(JSON.stringify(respuesta));
var activo = data.activo;
if(activo == "1"){
$scope.ValueResponse = true
} else {
$scope.ValueResponse = false
}
});
Now I need to control the function change()
The request to activate:
$scope.changed = Conection.OnMovil({
sucursal_id: SaveCredentials.getData().id_sucursal
}, function(response){
});
The request to deactivate:
$scope.changed2 = Conection.OffMovil({
sucursal_id: SaveCredentials.getData().id_sucursal
}, function(response){
});
Then with ng-change
I can put only one and when activating and deactivating it will always be executed ... how do I solve it? or how can I implement the code?