[英]AngularJS checkbox selected in a list
我有一個名為positions
的清單,其中有N個職位。 我也有一個用戶user
,該用戶具有一個屬性user.positions
,該屬性已分配了一些位置。
我想顯示一個表格,其中包含所有可能的位置,以及必須檢查用戶的位置。
這是我可以在HTML內部執行的操作,還是需要在我的邏輯中循環遍歷並創建一個新變量?
<label ng-repeat="position in positions">
<input type="checkbox" ng-checked="user.positions.indexOf(position) != -1" /> {{position}}
</label>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.