【问题标题】:How to Access kendo-window from Angular Directive?如何从 Angular 指令访问剑道窗口?
【发布时间】:2016-06-27 14:34:49
【问题描述】:

我有一个剑道窗口,我试图从 Angular 指令访问;具体来说,我希望能够将消息传递给窗口并使用它(作为弹出窗口),但我无法处理它。我尝试以与传递 $filter/$timeout 相同的方式将它作为参数传递给指令(见下文),并且我尝试使用如下代码直接访问它:

var alertMessageWindow = element.find("#customWindow");

或

var alertMessageWindow = jQuery(element).find('#customWindow');

我绝对是 Angular 指令的新手;到目前为止,我正在使用的那个工作正常;我只是无法访问剑道窗口。

这是我正在使用的代码的基础:

<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
        }
    };
}]);

【问题讨论】:

    标签: javascript angularjs kendo-ui


    【解决方案1】:

    在继续研究并在这里找到一篇很棒的文章之后, http://www.undefinednull.com/2014/02/11/mastering-the-scope-of-a-directive-in-angularjs/

    我找到了解决方案;通过将范围更改为 false 指令(基于我的阅读)不会被重置,因此使用 kendo-window 引用,

    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
        }
    };
    }]);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-10
      相关资源
      最近更新 更多