我想爲我的角度應用製作定製驗證指令。唯一的問題是,我不知道如何獲得一個價值角度定製驗證指令
<select class="form-control" ng-model="$parent.newSector" ng-options="item.id as item.name for item in sectors" not-empty-array="merchant.sectors"></select>
你可以從我的標記我有叫notEmptyArray這裏我設置一個表達式的指令看到(這是一樣的NG-模型,只是一個不同的表達)。我現在如何在我的指令中訪問它?
directive = function({
require: "ngModel",
link: function(scope, element, attributes, control) {
//how to access the value of merchant.sectors (its an array in the scope)
}
});
'scope.merchant.sectors'? – AlwaysALearner
是的,我可以這樣做,但「merchant.sectors」的一部分需要設置非空數組的值。所以如果我寫用戶作爲這個屬性的值。它應該檢查scope.users – Safari