0

I'm using AngularJS and have a switch, I want it to have that if the switch is turned off that my md-input-container is disabled by default. And when I click the switch to on that the md-input-container is enabled again.

What I have right now works a little bit, but when I want to turn the switch off again the md-input-container is still enabled.

My HTML code:

<div class="col-md-2"> <md-switch ng-click="enabled()"> Online verkoop </md-switch> </div> <div class="col-md-2"> <md-input-container class="md-block"> <label style="color: #e94e18;">Bezorgkosten (€)</label> <input ng-model="bezorgkosten" ng-disabled="disabled"> </md-input-container> </div> 

Javascript:

//disable switches $scope.disabled= true; $scope.enabled = (function(){ $scope.disabled = false; }); 

    1 Answer 1

    2
    $scope.enabled = (function(){ $scope.disabled = !$scope.disabled; }); 

    You can even get that function off the scope

    <md-switch ng-click="disabled = !disabled"> Online verkoop </md-switch> 
    0

      Start asking to get answers

      Find the answer to your question by asking.

      Ask question

      Explore related questions

      See similar questions with these tags.