Angularjs 角度控制器中未设置剑道ui通知范围变量
我注意到了其他剑道ui控件的这个问题,但我会特别询问剑道通知。我的html有:Angularjs 角度控制器中未设置剑道ui通知范围变量,angularjs,kendo-ui,angular-kendo,Angularjs,Kendo Ui,Angular Kendo,我注意到了其他剑道ui控件的这个问题,但我会特别询问剑道通知。我的html有: <span kendo-notification="vm.notifier"></span> <button ng-click="vm.push()">Push it</button> 我的问题是:如果我点击按钮,我会收到通知。但是,在加载时,我得到: TypeError:无法读取未定义的属性“show” 在激活时() 在新壳牌公司() 我确信我在Angular中遗漏
<span kendo-notification="vm.notifier"></span>
<button ng-click="vm.push()">Push it</button>
我的问题是:如果我点击按钮,我会收到通知。但是,在加载时,我得到:
TypeError:无法读取未定义的属性“show”
在激活时()
在新壳牌公司()
我确信我在Angular中遗漏了一些关于对象状态的信息,但是我遗漏了什么,我无法在控制器的加载阶段显示此通知?当您在控制器函数中调用activate时,Kendo UI小部件尚未创建。解决这个问题的一个方法是使用剑道UI在这个场景()中的一个全局事件: ()
(function () {
'use strict';
angular
.module('app.layout')
.controller('Shell', Shell);
function Shell() {
/*jshint validthis: true */
var vm = this;
vm.push = push;
activate();
function activate() {
vm.notifier.show('Loaded', 'info');
}
function push() {
vm.notifier.show('Pushed', 'info');
}
}
})();
angular.module('app.layout', [ "kendo.directives" ])
.controller('Shell', function ($scope) {
$scope.activate = function () {
$scope.notifier.show('Loaded', 'info');
};
$scope.push = function () {
$scope.notifier.show('Pushed', 'info');
};
$scope.$on("kendoRendered", function(event){
$scope.activate();
});
}
);