我使用ng-repeat
並設置與之類似以下當我需要ngModel控制器如何訪問
<div ng-repeat="thing in things" ng-model="thing" my-directive>
{{thing.name}}
</div>
模型中的模型控制器的屬性,然後在我的指令,它看起來像這樣
.directive("myDirective, function() {
return {
require: 'ngModel',
link: function(scope, lElement, attrs, model) {
console.log(model.name);// this gives me 'NAN'
}
}
})
我的問題是如何訪問模型中的值?我試過model.$modelValue.name
,但沒有奏效。
爲什麼下來投票? –