Z
Z
zagamay_ru2015-12-21 14:32:48
Angular
zagamay_ru, 2015-12-21 14:32:48

Why doesn't ngModel work in ngRepeat?

Hello! Tell me why the model in the input field does not work ..

<label ng-repeat="(key, val) in datas.options.sex">
        <input 
          type="checkbox" 
          ng-true-value="key" 
          ng-false-value="null" 
          ng-model="filter.sex[key]" 
          /> {{val}}
      </label>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Evgenievich, 2015-12-21
@zagamay_ru

It seems like ng-repeat creates its own scope. Try ng-model="$parent.filter.sex[key]"

Z
zagamay_ru, 2015-12-21
@zagamay_ru

thanks so he began to perceive the model, but another problem appeared

<div ng-repeat="(key, val) in datas.options.sex">
        <label>
          <input 
            type="checkbox" 
            ng-true-value="1" 
            ng-false-value="null" 
            ng-model="$parent.filter.sex[key]"
            /> {{val}}
        </label>
      </div>

ng-true-value="1" instead of 1 I put key and it stops working
In fact, there is a dynamic value - 1, 2, 3, and so on. I don't understand why I don't understand..

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question