【发布时间】:2014-12-17 00:57:10
【问题描述】:
我的页面中有一个 kendo-window,我希望每次单击命令时都将内容加载到其中。我要加载的内容来自 x-kendo-template 或来自 .html 的 angular {{Sample}} 表达式。加载内容后,我尝试 $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 Template
相同现在,当我使用 $compile 函数时,它会显示 $apply already in progress 的错误
任何帮助将不胜感激。 TIA
我还准备了JSFiddle
【问题讨论】:
标签: javascript angularjs kendo-ui kendo-window kendo-template