<div message-modal trigger="trigger_message_modal"></div>
错误消息:$scope.trigger_message_modal is not a function
NOT working directives.js
app.module.directive('messageModal', function ($compile) {
return {
scope: {
trigger: "=trigger"
},
controller: ['$scope', '$element', '$attrs', '$timeout', function ($scope, $element, $attrs, $timeout) {
$scope.trigger = function(title, message, modal_class, color, auto_hide){
$scope.message = message;
$scope.modal_class = modal_class;
$scope.color = color;
$scope.title = title;
$('#messageWell').modal('show');
if(auto_hide == true){
$timeout(function(){
$('#messageWell').modal('hide');
}, 1000)
}
};
}],
restrict: "E",
templateUrl :"well.html"
};
});
答案 0 :(得分:0)
该指令仅限于E,这意味着该指令应该用作元素,
struct Node{
int data;
Node* next;
};
。只有这样,<message-modal trigger="trigger_message_modal"> </message-modal>
属性才能在指令中使用指令的范围。
如果您需要将trigger
用作属性,请将限制更改为message-modal
,但您将无法访问A
作为范围变量,并且需要使用父元素的trigger
。