2014-10-19 80 views
0

我正在檢查單選按鈕的值是否存在,然後顯示。我有幾個帶商店名稱的單選按鈕,當用戶選擇一個按鈕時,它會顯示該商店的人員。當我的收音機型號發生變化時,ng-show不會更新

代碼工作,如果我檢查正常的字符串值

<!-- this works because 'West' isn't {{radio.model}} --> 
<tr ng-show="user.store.indexOf('West') != -1" data-ng-repeat="user in users"> 

然後我更改代碼以這種

<!-- this breaks it. Selecting user buttons will show the store name as text where it says {{radio.model}}, but it won't ng-show the users --> 
<tr ng-show="user.store.indexOf({{radio.model}}) != -1" data-ng-repeat="user in users"> 

這是我組單選按鈕

<label class="btn btn-primary" ng-repeat="store in global.user.store" ng-model="radio.model" btn-radio="store" uncheckable>{{store}}</label> 
{{radio.model || 'null'}} 

這是我的角度控制器

// fixes the scope problem with ng-model 
$scope.radio = {model: null}; 

我會檢查單選按鈕,它會在頁面上顯示West(它表示{{radio.model}})...但West用戶不會看到。

回答

0

我刪除了{{和}}括號,它的工作原理。我意識到角度控制器說$ scope.radio =型號:空,所以我可以直接在html中訪問radio.model沒有括號。