nirvair
nirvair

Reputation: 4180

ng-click not updating value in ng-repeat

This is the code:

<div ng-repeat="data in products">
    <div class=edit ng-click="dataUI.showEdit = true; content = data;">
    </div>
    <div ng-repeat="renew in data.renewed">
        <div class=edit ng-click="dataUI.showEdit = true; content = renew;">
        </div>
    </div>
</div>
<div class="modal" ng-show="dataUI.showEdit">
    <div class="product_price">{{content.product_price}}</div>
</div>

When I click this, the popup opens but, the content is not filled with items. In the popup, I am using content to show the data.

What am I doing wrong here?

JSFiddle: http://jsfiddle.net/HB7LU/22082/

Upvotes: 0

Views: 336

Answers (1)

masa
masa

Reputation: 2820

Here's your fiddle fixed: http://jsfiddle.net/masa671/xtaa9gev/

You were using an old version of Angular, changed to version 1.4.8 (see the JavaScript Gear).

Then, a couple of missing injections:

MyCtrl.$inject = ['$scope'];
myApp.controller('MyCtrl', MyCtrl);

Finally, assignment to content in ng-click did not work, because ng-repeat creates a new scope ("Always use a dot"). I fixed this with dataUI.content. Here is one good explanation: Ng-click doesn't work inside ng-repeat.

Upvotes: 1

Related Questions