2018年11月8日 星期四

ui-select 於 ng-repeat 中綁定變數屬性方式

<div ng-repeat="a in list">
<ui-select append-to-body="true" ng-change="a['收件人id']=a['收件人物件'].value;" ng-model="a['收件人物件']">
                        <ui-select-match allow-clear="true">
                            <span ng-bind="$select.selected.text"></span>
                        </ui-select-match>
                        <ui-select-choices repeat="obj in employees | filter: $select.search track by $index">
                            <span ng-bind="obj.text"></span>
                        </ui-select-choices>
                    </ui-select>

因為ui-select ng-model 對應的是 repeat 中的元素,若該元素是物件,但希望改成對應ng-repeat物件某個屬性(收件人id),則需要另外用屬性物件(收件人物件)來轉換,且若考慮既有資料預設值,陣列元素也需要先設定好該屬性物件,以便正確顯示目前的選項

沒有留言:

自訂權限驗證機制

// 使用 filter [Route("api/[controller]")] [ApiController] [Authorize] [TypeFilter(typeof(CustomAsyncAuthorizationFilter))] public c...