2

Im having a issue with hiding elements. Basically i want to set defaults for what elements are hidden/shown when the page is loaded.

Im hiding my elements via the ng-hide that is bound to a model that is set from the controller, and ng-repeated over in the view.

The checkbox is bound correctly, but the content in not hidden by default, you will have to click the checkbox twice for it to correctly hide the element.

Demo is found here: Plunker

2
  • when it is "checked" you want to hide a relevant column or to show it? Commented Oct 17, 2013 at 10:40
  • I was thinking of hiding the columns when the checkbox is checked Commented Oct 17, 2013 at 10:42

2 Answers 2

2

It works when these models are defined. You can use ng-init for this purpose:

 ng-init="$parent[col.model]=col.checked"

Working plnk: http://plnkr.co/edit/pUAufB?p=preview

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

1 Comment

@PatrikStorm this way (Q&A) is my best way for learning stuff !
1

The first time odd behaviour is due to you mobile property checkedContainer has not been created till the binding is evaluate based on your interaction with the checkboxes.

In the controller if you do

$scope.checkedContainer=true; your code would work.

1 Comment

Thanks for your help! I got it figured out. As i could have guessed, a scoping issue..

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.