我想知道创建控制器的这两种方法的用例是什么:
使用ngController:
- myApp.controller('myController',['$scope',function ( $scope ) {
- }]);
在控制器属性的指令中构造控制器:
- myApp.directive ( 'myDirective',[ '$window',function( $window ) {
- return {
- restrict: 'A',controller: [ '$scope',function( $scope ) {
- }],link: function( scope,element,attrs ) {
- }
- };
- }]);
如果在同一个元素上调用了这个指令,那么你有没有理由不构造控制器?
这只是一个问题,控制器的使用/复杂程度如何?