0

So i have this html. The issues is that is changing the model(filter) when i select one of those that i have create in a static way but the dynamic ones does not trigger the change of the value. Any ideas?

Thanks.

<div class="row">
        <div class="col-xs-6">
            <h3>Group 1</h3>
            <hr>
            <div class="checkbox">
                <input type="radio" name="filterGroup" ng-model="filter" ng-value="5"><label>5</label>
            </div>
            <div class="checkbox">
                <input type="radio" name="filterGroup" ng-model="filter" ng-value="4'"><label>4</label>
            </div>
        </div>
        <div class="col-xs-6">
            <h3>Group 2</h3>
            <hr>
            <div class="checkbox">
                <input type="radio" name="filterGroup" ng-model="filter" ng-value="3"><label>3</label>
            </div>
            <div class="checkbox">
                <input type="radio" name="filterGroup" ng-model="filter" ng-value="2'"><label>2</label>
            </div>
            <div class="checkbox">
                <input type="radio" name="filterGroup" ng-model="filter" ng-value="1"><label>1</label>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-xs-6">
            <h3>DinamicItems</h3>
            <hr>
            <div class="checkbox" ng-repeat="item in items">
                <input type="radio" name="filterGroup" ng-model="filter" ng-value="'{{item.value}}'"><label>{{item.text}}</label>
            </div>
        </div>
    </div>
1
  • 4
    it's because you are breaking the rule of always using an object in ng-model. Using ng-repeat creates child scopes and therefore you break 2 way binding when using a primitive Commented May 24, 2016 at 22:08

1 Answer 1

2

What Charlie is saying is, your model of tag is a primitive one. Each instance of ng-repeat creates it's own scope. Therefore, your models, although named 'tag', are not in fact the same.

To remedy, you should make your model something like vm.tags (vm = view model.)

A few things to read up on, and learn more:

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

1 Comment

i resolve it by adding ng-click and updating the model in a function. Thanks

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.