Programming language/Angularjs(1.x)
Module.config / Module.constant / Module.run
hello-world
2017. 1. 24. 21:19
728x90
반응형
Module.config / Module.run 공통~
- 앱의 생명주기상 주요 시점에 호출되는 함수를 등록한다.
Module.config - 모듈 설정 코드. config 메서드를 호출한 모듈이 로드된 후 호출할 함수를 인자로 받는다.
- controller/service/factory/provider 등은 config메서드의 축약형태
즉 아래와 같이 표현 될 수 있다.
angular.module('모듈이름', []).
controller('컨트롤러이름', ....);
angular.module('모듈이름', []).
config(function($controllerProvider) {
controllerProvider.register('컨트롤러이름', ...);
});
참조 URL : http://webframeworks.kr/tutorials/angularjs/app_structure_with_module/
Module.run - run 메서드의 인자로 넘겨준 함수는 모든 모듈이 로드될 때 호출된다.
Module.constant - 상수값을 정의해 줌. constant메서드는 config메서드에 의해 의존성이 선언될 수 있는 서비스를 생성한다.
728x90
반응형