2
我正在創建一個小應用程序,並且該模板具有以下指令。使用替換時,模板中不可見的角度隔離範圍值
smallgrid.directive.js:
angular.module('myActions')
.directive('smallgrid', ['$rootScope', function($rootScope) {
return {
restrict: "E",
scope: {
actionable: "="
},
controller: function($scope) {
$scope.setLocation = function() {
console.log("yee");
};
}
};
}])
.directive('three', function() {
return {
replace: true,
templateUrl: '/app/my_actions/directives/templates/grid3x3.template.html'
};
})
.directive('four', function() {
return {
replace: true,
templateUrl: '/app/my_actions/directives/templates/grid4x4.template.html'
};
})
.directive('five', function() {
return {
replace: true,
templateUrl: '/app/my_actions/directives/templates/grid5x5.template.html'
};
});
grid3x3.template.html
<div class="k-edit-field" id="board">
<div class="row" ng-click="setLocation()">
{{actionable.probability}}
</div>
</div>
我使用這個指令如下:
<smallgrid three actionable="currentAction.actionable" ng-if="somecondition"></smallgrid>
的UI呈現正常。但是,它顯示{{actionable.probability}}
是空的,並且Click事件未觸發。但是,如果我刪除隔離的作用域並直接訪問該變量,則值可用。我知道當我使用隔離示波器時,在three
指令中,我無法訪問smallgrid
的值。有沒有辦法將smallgrid
中的值傳遞給模板?
真棒。感謝您的描述性答案。 –