我有一个像这样的html模型:
<tbody>
<tr ng-repeat="row in objectData.Tables[1].Dataset">
<td ng-repeat="col in objectData.Tables[1].Columns | filter:isColumnVisible | filter:skipColumnHiden" ng-click="items.SetSelected(objectData.Tables[1],row.$$hashKey)"
ng-class="{'dd-selected': objectData.Tables[1].$ddSelected===row.$$hashKey, 'dd-vh-2':col.Length<=25 , 'dd-vh-5':col.Length>25 && col.Length<=50, 'dd-vh-10':col.Length>50 && col.Length<=100, 'dd-vh-15':col.Length>100 && col.Length<=150, 'dd-vh-20':col.Length>150 && col.Length<=250}">
<div ng-switch="col.Type" ng-hide="objectData.Tables[1].$ddSelected===row.$$hashKey || ($index==0 && row.showRowButtons == true)">
<span ng-switch-when="Integer" class="dd-cell">{{row[col.Code] | number}}</span>
<span ng-switch-when="Date" class="dd-cell">{{row[col.Code] | date}}</span>
<span ng-switch-when="DateTime" class="dd-cell">{{row[col.Code] | date}}</span>
<span ng-switch-when="Decimal" class="dd-cell">{{row[col.Code] | number}}</span>
<span ng-switch-when="Currency" class="dd-cell">{{row[col.Code] | currency}}</span>
<span ng-switch-default class="dd-cell">{{row[col.Code]}}</span>
</div>
<div class="row" ng-show="objectData.Tables[1].$ddSelected===row.$$hashKey" ng-switch="col.Type" style="clear:both" dd-stop-click>
<input ng-switch-when="Integer" class="form-control input-sm" type="number" ng-model="row[col.Code]" ng-required="col.Required" />
<input ng-switch-when="Decimal" class="form-control input-sm" type="number" ng-model="row[col.Code]" ng-required="col.Required" />
<input ng-switch-when="Currency" class="form-control input-sm" type="number" ng-model="row[col.Code]" ng-required="col.Required" />
<input ng-switch-when="Date" class="form-control input-sm" type="date" ng-model="row[col.Code]" ng-required="col.Required" />
<input ng-switch-when="DateTime" class="form-control input-sm" type="datetime" ng-model="row[col.Code]" ng-required="col.Required" />
<input ng-switch-when="Boolean" class="form-control input-sm" type="checkbox" ng-model="row[col.Code]" />
<dd-combo-grid ng-switch-when="Relation" ng-model="row[col.Code]" dd-object="{{col.Class}}" dd-selected="ddSelected(objectId)" dd-template="/Template/Modal/Table"></dd-combo-grid>
<input ng-switch-default class="form-control input-sm" type="text" ng-model="row[col.Code]" ng-required="col.Required" />
</div>
</td>
</tr>
</tbody>
制定问题的指令是dd-combo-grid
女巫看起来像这样:
var ComboGridDirecitve = function () {
return {
restrict: 'E',
scope: {
ddObject: '@',
ddId: '=ngModel',
ddName: '=',
ddSelected: '&',
ddParent:'=',
ddTemplate: '@',
globals: '=globals',
ddReplace: '@'
},
require: 'ngModel',
templateUrl: 'Template/ComboGrid',
controller: 'ModalObjectController',
link: function (scope, element, attrs) {
scope.ddModal = false;
scope.isChanged = false;
scope.ddModalTemplate = '';
}
}
}
指令定义ddId
在=
绑定ngModel
问题在于,由于某种原因,ddId
更新未传播到指令的ngModel
控制器代码:
$scope.ddId = r['code'];
console.log('selected Id:', $scope.ddId);
日志返回正确的值。
如果由于某种原因未在ngRepeat中使用
,则该指令有效有什么想法吗?