2015-02-05 1 views
1

다른 kendo-ui 컨트롤에서이 문제를 발견했는데 특별히 kendo-notification에 관해 질문 할 것입니다. 내 HTML을 가지고 내 컨트롤러에서각도 조절기에서 kendo-ui 알림 범위 변수가 설정되지 않았습니다.

<span kendo-notification="vm.notifier"></span> 
<button ng-click="vm.push()">Push it</button> 

나는이 :

(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'); 
    } 

} 
})(); 

내 문제 : 나는 버튼을 클릭하면, 나는 알리미를 얻을. 그러나로드에, 내가 얻을 : 형식 오류 : 새로운 쉘에서 활성화 (http://localhost:57624/app/layout/shell.controller.js:41:24) 에서 정의되지 않은 의 특성 '쇼'를 읽을 수 없습니다 (http://localhost:57624/app/layout/shell.controller.js:32:9)

난에서 객체 상태에 대해 뭔가를 누락 확신 각도가 맞지만 컨트롤러의로드 단계에서이 알림을 표시 할 수 없다는 점은 무엇입니까?

답변

1

컨트롤러 기능에서 activate를 호출하면 Kendo UI 위젯이 아직 생성되지 않았습니다. 이 문제를 해결하는 한 가지 방법은이 시나리오의 검도 UI가 가지고있는 글로벌 이벤트 중 하나 (kendoRendered)를 사용하는 것입니다 :

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

(demo)

+0

큰 일했다, 감사합니다! –