Reputation: 277
I would like to hide a button in my form, once it's submitted and everything is working fine, I need to hide it and show something else, is there a way to do in my controller:
this.show= false;
Or do I need to add ng-show to the button and implement a variable to set to hide it?
Upvotes: 2
Views: 171
Reputation: 3
in controller
$scope.condition = true;
$scode.activeCondition = function (con) {
$scope.condition = !con;
};
in html
<button type="button" ng-class="{'active': condition}" ng-click="activeCondition(condition)">
Upvotes: 0
Reputation: 28359
Instead of adding new variables, why not using what is already designed for that. In the angular object representing your form, there is a $submitted
property.
Therefore, providing your form is named myForm, something like that should do the trick:
<button ng-if="!myForm.$submitted">Button</button>
See official guide about forms in angular
Upvotes: 1
Reputation: 10313
You could use ng-class:
ng-class="{'some-class': !some.object.user, 'some-other-class': some.object.user}"
Upvotes: 2