1

i have the below ng-repeat

<span ng-repeat = "x in levels">
    <input id="{{x}}" type="checkbox" ng-model="Filter.level.{{x}}" ng-true-value="{{x}}"  data-ng-false-value=""/><label for="{{x}}">{{x}}</label>
</span>

im facing issue with the value of ng-model directive

i tried to use it many ways but it didnt work:

ng-model="Filter.level.{{x}}" 

or

ng-model="'Filter.level.'+{{x}}" 

or

ng-model="'Filter.level.'+'{{x}}'" 

or

ng-model="'Filter.level.level'+{{$index}}"

its work only when i use it like ng-model="Filter.level.level1"

but i need the value to be dynamic from ng-repeat like Filter.level.level1, Filter.level.level2 ...

1 Answer 1

2

You should access object by index there with the help of [], you can't use {{}}(interpolation directive) inside ng-model

ng-model="Filter.level[x]"
Sign up to request clarification or add additional context in comments.

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.