Mustafa Bereket
Mustafa Bereket

Reputation: 129

ng-repeat with hashmap doesn't display anything on my html table

I am trying to display a table with hashmap values.

my js hashmap is following:

self.userList["user1"] = {sms:true,email:false}
self.userList["user2"] = {sms:false,email:false}
self.userList["user3"] = {sms:true,email:true}
self.userList["user4"] = {sms:false,email:false}

and my view is following:

<tr ng-repeat="(user,value) in editRulesCtrl.userList">
                                <td>
                                     {{user}}
                                </td>
                                <td>
                                  <md-checkbox ng-model="{{value.sms}}"></md-checkbox>
                                </td>
                                <td >
                                   <md-checkbox ng-model="{{value.email}}"></md-checkbox>
                                </td>
</tr>

Not sure what I am doing wrong, but table shows up empty.

Upvotes: 1

Views: 145

Answers (2)

Pankaj Parkar
Pankaj Parkar

Reputation: 136174

This should work, only problem I can see is, ng-model needs variable name, it does failed if you try to pass {{}}(interpolation) to it.

<tr ng-repeat="(user,value) in editRulesCtrl.userList">
    <td>
      {{user}}
    </td>
    <td>
      <md-checkbox ng-model="value.sms"></md-checkbox>
    </td>
    <td>
      <md-checkbox ng-model="value.email"></md-checkbox>
    </td>
</tr>

Plunker

Upvotes: 2

Jarek Kulikowski
Jarek Kulikowski

Reputation: 1389

<tr ng-repeat="(user,value) in userList">

Upvotes: 0

Related Questions