簡體   English   中英

angular ng-checked 不適用於收音機 - 2

[英]angular ng-checked is not working for radio - 2

<input type="radio" ng-checked="pooledFunds.acceptPooledFunds == 1">

<input type="radio" ng-checked="pooledFunds.acceptPooledFunds == 1"> {{pooledFunds.acceptPooledFunds}} , {{pooledFunds.acceptPooledFunds == 1}}

我有一個 JSON 對象分配給我的控制器中的范圍變量,例如

$scope.pooledFunds = {"acceptPooledFunds" : 1};

使用 {{pooledFunds.acceptPooledFunds}} 打印時 pooledFunds.acceptPooledFunds 的值顯示為 1,而 {{pooledFunds.acceptPooledFunds == 1}} 顯示為 true。

但是單選按鈕沒有變成選中模式。 我已經檢查過這個鏈接: angular ng-checked 不適用於收音機

它沒有幫助。

嘗試這個

<input type="radio" ng-model="pooledFunds.selectedVal" name="pooled" />

<input type="radio" ng-model="pooledFunds.selectedVal" name="pooled" />

Javascript

$scope.pooledFunds.selectedVal = 1; 

使用ng-model ,如果您將模型的值設置為 true/false,那么它應該可以工作。

工作演示

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM