0
我試圖將我的ng-repeat
本地對象傳遞給指令。我需要從我的指令控制器中訪問該對象的數據。我很困惑iso-lated scope
和控制器範圍。爲什麼它不起作用。將ng-repeat本地對象傳遞給指令控制器不起作用
Demo搗鼓什麼我想
HTML
<div ng-app="my-app" ng-controller="MainController">
<div ng-repeat="document in documents">
<name-row
document-element="document">
</name-row>
</div>
</div>
指令
module.directive('nameRow', function() {
return {
restrict: 'E',
replace: true,
scope: {
documentElement : '=document',
},
controller: function($scope) {
console.log($scope.documentElement);
},
template:
' <ul>' +
' <li>' +
' <a>' +
' {{documentElement.targetPrice}}' +
' </a>' +
' </li>' +
' </ul>'
};
});
我只想ŧ o明白爲什麼它不起作用。我不想像鏈接等功能
無需明確有'= documentElement'只有'='是罰款 –
@PankajParkar感謝 –