0

I have the following code,

<accordion-group ng-class={selected : object.property}></accordion-group>
<input type="button" ng-click="object.property=!object.property">

When I run the above code, on load of application, object.property is true and the css is applied. On click of button, css property is removed. On click of button again, css is not getting applied.

Note: This worked with the previous versions of angular and bootstrap. I recently got upgraded to angular1.4.1 and bootstrap 0.13.0. I suspect this is because of latest version update, but, could not find a valid documentation for me to conclude.

Thanks in advance.

2
  • 1
    Did you meant <input type="button" ng-click="object.property = !object.property"> Commented Jul 13, 2015 at 11:29
  • Yes, my apologies, updated the question. Commented Jul 13, 2015 at 11:50

1 Answer 1

1
<input type="button" ng-click="object.property = !object.property">

And I prefear ng-class like this:

ng-class="{'selected' : property}"

since on the left part of the : operator there will be surely a string!

And here is a PLNKR.

Sign up to request clarification or add additional context in comments.

4 Comments

I have this solution, sorry for not mentioning it in the question, I need the reason why we need to directly refer property over object.propery. Could you please enhance your answer? That would be a great help. Thanks.
Yes, I resolved it, but could not understand exactly, why we cannot give ng-class="{'selected' : object.property}"
This should depend on what you have in controller, I've update plunker, now it refear to an object.property like property and still works...
I don't know the reason, it will not work with <accordion-group></accordion-group>

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.