2013-06-02 6 views
1

각도 j의 지시어를 정의하는 구문은 2 가지입니다.지시어를 올바르게 정의하는 방법은 무엇입니까?

첫 번째 방법은 다음과 같습니다

angular.module("map-mcbjam", []); 
angular.module("map-mcbjam", []).directive('map', function() { ...}) 

두 번째 방법은 다음과 같습니다

angular.module("map-mcbjam", ['directives']); 
angular.module('directives', []).directive('map', function() { ...}) 

이 soemone 그 두 방법 사이의 차이를 설명하는 방법을 알 수 있습니까?

답변

2

두 번째 방법은 여러 모듈 사이의 지침을 공유 할 수 있습니다 :

angular.module("map-mcbjam", ['directives']); 
angular.module("map2-mcbjam2", ['directives']); 
angular.module("map3-mcbjam3", ['directives']); 

angular.module('directives', []).directive('map', function() { ...}) 

당신이 당신의 지시어는 모듈 지도 - mcbjam 외부 유용 할 수 있습니다 생각한다면, 당신은 그래서 두 번째 방법을 사용해야합니다 당신 그것을 재사용 할 수 있습니다.

관련 문제