Leandro Leandro - 1 year ago 121
AngularJS Question

change text when click on md-switch angular-material

i'm using angular-material to build a app, but i have a list component with a text Disabled, it is a option using md-switch, so, i'm trying make this text change to Enabled when i click in that switch

Answer Source

Try the ng-change documentation: https://docs.angularjs.org/api/ng/directive/ngChange

And as in documentation, in html:


<md-switch aria-label="switch" ng-change="changeText(model)" ng-model="model">

And in the controller:

$scope.changeText = function(model){
       $scope.text = "Enabled";
       $scope.text = "Disabled"

Hope it helps =)