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
中的值传递给模板?
真棒。感谢您的描述性答案。 –