2014-01-17 15 views
0

사용자 지정 textAngular 지시문 옵션을 사용하고 싶습니다.

API 문서에 $ rootScope.textAngularTools. {customButton}을 설정하여 함수를 작성해야한다고 나와 있습니다.

컨트롤러에 설정하면 지시문에서 속성이 정의되지 않는다고 알립니다.

module.run 함수를 설정하면 $ rootScope.textAngularTools가 정의되지 않습니다.

어떻게 지시문을 초기화하기 전에 옵션을 설정합니까?

<text-angular to-toolbar="[['customButton']]"> 

내가 제안 소스를 읽고이 (커피 스크립트) 같은

$rootScope.textAngularTools.colourRed = 
    display: "<button ng-click='action()' ng-class='displayActiveToolClass(active)'><i class='fa fa-square' style='color: red;'></i></button>", 
    action: -> 
    console.log 'action' 
    activeState: -> 
    false 

답변

2

설정 당신은 모듈의 실행 기능의 구성을 수행

angular.modul('myApp', ['textAngular']) 

.run(function($rootScope){ 
    $rootScope.textAngularTools = { 
     colourRed: { 
       display: "<button ng-click='action()' ng-class='displayActiveToolClass(active)'><i class='fa fa-square' style='color: red;'></i></button>", 
       action: function(){ 
       console.log('action); 
       } 
     } 
    }; 
}) 

.controller('yourController')... 

왜이 일해야?

$rootScope.textAngularTools != null)? $rootScope.textAngularTools : {} 
+0

귀하의 제안에 감사드립니다. 그러므로 $ rootScope는 각도가있는 모든 컨트롤러 $ 범위의 프로토 타입입니까? 다시 고마워요 :) –

+1

@ Chai-YuPai 예. – michael

관련 문제