刷新内容后编译剑道窗口
Compile kendo window after refresh content
我的页面中只有一个剑道窗口,每次单击命令时都想将内容加载到其中。我要加载的内容要么来自 x-kendo 模板,要么来自带有角度 {{Sample}} 表达式的.html。加载内容后,我试图$compile内容以使用角度绑定,但它不起作用。这就是我到目前为止尝试过的
在我的标记上
<base href="http://demos.telerik.com/kendo-ui/grid/angular">
<script id="tplAddNew" type="text/x-kendo-template">
Action in Add New: {{ Action }}
</script>
<script id="tplView" type="text/x-kendo-template">
Action in View: {{ Action }}
</script>
<div id="example" ng-app="Test">
<div ng-controller="MyCtrl">
<div kendo-window="winTesting"
k-visible="false"
k-modal="true"
k-pinned="true"
k-width="'500px'"
k-min-height="'200px'">
</div>
<button
kendo-button
ng-click="AddEntry()">Add Entry</button>
<button
kendo-button
ng-click="ViewContent()">View Content</button>
</div>
</div>
这是我的控制器
var app = angular.module("Test", ["kendo.directives"]);
app.controller("MyCtrl", [
"$scope", "$compile",
function($scope, $compile) {
$scope.AddEntry = function() {
$scope.Action = "Add New";
$scope.winTesting
.refresh({
//url: '../References/Test-entry.html'
template: kendo.template($('#tplAddNew').html())
})
.setOptions({
title: "Create New User"
});
//$scope.$apply(function() {
// $compile($scope.winTesting.element)($scope);
//});
$scope.winTesting.open().center();
}
$scope.ViewContent = function() {
$scope.winTesting
.refresh({
//url: '../References/View-entry.html'
template: kendo.template($('#tplView').html())
})
.setOptions({
title: "View User Detail"
});
//$scope.$apply(function() {
// $compile($scope.winTesting.element)($scope);
//});
$scope.winTesting.open().center();
}
}
]);
假设 Test-entry.html 的内容与 tplAddNew 模板相同
现在,当我使用 $compile 函数时,它将显示一个错误 $apply 已经在进行
中任何帮助将不胜感激。蒂亚
我还准备了一个JSFiddle
Kendo 还没有真正完善这个小部件。 因此,鉴于此,请使用$timeout服务:
$timeout(function() {
$compile($scope.winTesting.element)($scope);
}, true);
最后一个布尔参数(或多或少)执行 $scope.$apply。 查看文档
编辑:
您还可以使用$parse服务做一些很酷的事情。 您可能会发现它很有用,如本博客中所述
相关文章:
- 创建一个类似链接的按钮,并通过Javascript函数打开一个新的弹出窗口
- 防止Iframe窗体在新窗口中打开
- 内部分区字体大小获胜'调整浏览器窗口大小时不会随媒体查询而更改
- 调整窗口大小时,可拖动的对象会出现在容器外部
- Javascript排序的图像弹出窗口..可以't单独弹出
- 窗口大小html css
- 弹出窗口出现,然后退出
- 为什么不是't窗口.恢复正常工作吗?(javascript/jquery)
- Javascript更新孙窗口中的表单元素
- 如何在选项卡上定义属性'的主窗口对象
- CSS-若窗口太小,滚动条会出现在“表格”单元格上
- 召回窗口加载事件 - javascript
- 为什么不显示警报窗口
- 如何使用modalDialog来显示可以在所有浏览器中工作的弹出窗口
- Chrome应用程序调整窗口大小保持纵横比
- 新选项卡被弹出窗口阻止程序阻止
- 如何访问UIWebView'的子窗口上下文
- 刷新父窗口后无法关闭窗口
- 角度:编译谷歌地图信息窗口内容以使用ng-click
- 刷新内容后编译剑道窗口