默認情況下我應該選中一個單選按鈕選項。 我試圖給ng-model
和ng-init
,但它不工作。如何使默認情況下選中一個單選按鈕選項
我的HTML:
<div bindonce ng-repeat="row in results.favorites" style="padding: 0px 10px; white-space: nowrap; border-bottom: 1px solid #efefef; border-top: 1px solid #eee; border-left: 1px solid #efefef;">
<input type="radio" ng-click="setFavoriteDashboard(row.id)" ng-model="selectedRow" name="favRadioSel" style="opacity: 1;" class="pointer"/>
<span bo-text="row.title" style="margin: 10px; position: relative; top: 3px;"></span>
</div>
我的JS:
$scope.results = {
favorites: [{
id: "WatchList1",
title: "WatchList1"
}, {
id: "WatchList2",
title: "WatchList2"
}, {
id: "WatchList3",
title: "WatchList3"
}]
};
$scope.selectedRow = "WatchList1";
演示:http://plnkr.co/edit/KA9HyQ3bHxJo2Cm9qFm3?p=preview
範圍變量應在parent..rather比在礦井答案'NG-repeat'..look .. –