2

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?

1
  • you could use ng-if there like ng-if="vm.show". . Commented Sep 27, 2015 at 21:03

4 Answers 4

2

You could use ng-class:

ng-class="{'some-class': !some.object.user, 'some-other-class': some.object.user}"
Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

0

Other option would be to use ng-style to do the job:

1 Comment

ng-style you would need to add style to .css file and use extra variable.
0

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)">

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.