Abstract class를 상속(inherits)하여 구현하는 예제입니다.
Controller 생성자에 $controller를 전달한 뒤 아래 예제와 같은 형태로 상속이 가능합니다.
$scope를 injecting하기 위해서 두 번째 param를 전달합니다.
기술적으로 상속이 아니기 때문에 title을 implement라고 한 듯 하네요. :)
이를 이용하면 duplicate code between controllers 상황을 해결할 수 있습니다.
References
http://jasonwatmore.com/post/2014/03/25/angularjs-a-better-way-to-implement-a-base-controller
'Programming > AngularJs' 카테고리의 다른 글
ngOptions, how to use repeat object in select. (0) | 2015.12.03 |
---|