简体   繁体   English

从Angular 1.5组件参考Kendo窗口

[英]Reference Kendo Window from Angular 1.5 component

I have an Angular 1.5 (with components) application. 我有一个Angular 1.5(带有组件)应用程序。 I am using Kendo UI as a front end framework. 我正在使用Kendo UI作为前端框架。

I have a window defined as: 我有一个定义为的窗口:

 <div kendo-window="wSearch" k-title="'Search Results'" k-visible="false" k-actions="['Close']" k-width="'600px;'" k-height="'500px'"> <h2>Search Results</h2> </div> 

The problem I am having is opening the window from the component. 我遇到的问题是从组件打开窗口。 If I want to open the window from a button directly I could do that: 如果我想直接通过按钮打开窗口,可以这样做:

 ng-click="wSearch.center().open()" 

The issue is that I need to perform some logic before opening the window so I need to open it from code, not the markup. 问题是我需要在打开窗口之前执行一些逻辑,因此我需要从代码而不是标记中打开它。

How can I reference wSearch from code? 如何从代码中引用wSearch?

Thank you. 谢谢。

For those of view, facing the same issue, here is how I resolved it: 对于那些观点相同的人,这里是我如何解决它:

in the click method: 在点击方法中:

 $scope.wSearch.center().open(); 

just make sure that $scope is injected in the component definition. 只需确保将$ scope注入组件定义中即可。

I am not sure if this is the best way to do that. 我不确定这是否是最好的方法。 I know that the use of $scope is discouraged when using components, but I could not find any other way to achieve that. 我知道在使用组件时不鼓励使用$ scope,但是我找不到其他方法来实现。

Hope that helps. 希望能有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM