Javascript 如何从Angular指令访问剑道窗口?
我有一个剑道窗口,我试图从一个角度指令访问它;具体来说,我希望能够将消息传递到窗口并使用它(作为弹出窗口),但我无法对其进行处理。我尝试将其作为参数传递给指令,传递方式与传递$filter/$timeout的方式相同(请参见下文),并尝试使用以下代码直接访问它:Javascript 如何从Angular指令访问剑道窗口?,javascript,angularjs,kendo-ui,Javascript,Angularjs,Kendo Ui,我有一个剑道窗口,我试图从一个角度指令访问它;具体来说,我希望能够将消息传递到窗口并使用它(作为弹出窗口),但我无法对其进行处理。我尝试将其作为参数传递给指令,传递方式与传递$filter/$timeout的方式相同(请参见下文),并尝试使用以下代码直接访问它: var alertMessageWindow = element.find("#customWindow"); 或 我绝对是个新手;到目前为止,和我一起工作的人工作得很好;我就是无法进入剑道窗口 这是我正在使用的代码的基础: <
var alertMessageWindow = element.find("#customWindow");
或
我绝对是个新手;到目前为止,和我一起工作的人工作得很好;我就是无法进入剑道窗口
这是我正在使用的代码的基础:
<div kendo-window="customWindow"
k-options="customWindowOptions">
</div>
appModule.directive("myDirective",['$filter','$timeout',
function($filter, $timeout){
return {
restrict:'A',
scope:{
number:'=',
max:'=?',
min:'=?'
},
link: function(scope, element, attr) {
//access kendo-window here
}
};
}]);
指令(“myDirective”[“$filter”,“$timeout”,
函数($filter,$timeout){
返回{
限制:'A',
范围:{
编号:'=',
最大值:“=?”,
最小:'=?'
},
链接:功能(范围、元素、属性){
//进入剑道窗口
}
};
}]);
在继续研究并在这里找到一篇很棒的文章之后,
我找到了解决办法;通过将作用域更改为false,指令(基于我的读数)不会重置,因此使用
scope.customWindow
现在可以工作了
appModule.directive("myDirective",['$filter','$timeout',
function($filter, $timeout){
return {
restrict:'A',
scope:false,
link: function(scope, element, attr) {
//access kendo-window here using scope.customWindow
}
};
}]);
appModule.directive("myDirective",['$filter','$timeout',
function($filter, $timeout){
return {
restrict:'A',
scope:false,
link: function(scope, element, attr) {
//access kendo-window here using scope.customWindow
}
};
}]);