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?
您可以使用ng-class:
ng-class="{'some-class': !some.object.user, 'some-other-class': some.object.user}"
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>
另一种选择是使用ng-style做这项工作:
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)">
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.