diff options
| author | Igor Minar | 2012-03-26 13:01:24 -0700 |
|---|---|---|
| committer | Igor Minar | 2012-03-26 15:23:29 -0700 |
| commit | d54dfecb00fba41455536c5ddd55310592fdaf84 (patch) | |
| tree | fa146933a2056b69c558f8e0bc0d15a315afeaaa /test/directive/ngViewSpec.js | |
| parent | 4b8d926062eb4d4483555bdbdec4656f585ab40b (diff) | |
| download | angular.js-d54dfecb00fba41455536c5ddd55310592fdaf84.tar.bz2 | |
feat($controller): support controller registration via $controllerProvider
It's now possible to register controllers as:
.register('MyCtrl', function($scope) { ... });
// or
.register('MyCtrl', ['$scope', function($scope) { ... });
Additionally a module loader shortcut api was added as well:
myModule.controller('MyCtr', function($scope) { ... });
Diffstat (limited to 'test/directive/ngViewSpec.js')
| -rw-r--r-- | test/directive/ngViewSpec.js | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/directive/ngViewSpec.js b/test/directive/ngViewSpec.js index 52aefa3a..636e15a8 100644 --- a/test/directive/ngViewSpec.js +++ b/test/directive/ngViewSpec.js @@ -54,6 +54,25 @@ describe('ng-view', function() { }); + it('should support string controller declaration', function() { + var MyCtrl = jasmine.createSpy('MyCtrl'); + + module(function($controllerProvider, $routeProvider) { + $controllerProvider.register('MyCtrl', ['$scope', MyCtrl]); + $routeProvider.when('/foo', {controller: 'MyCtrl', template: '/tpl.html'}); + }); + + inject(function($route, $location, $rootScope, $templateCache) { + $templateCache.put('/tpl.html', [200, '<div></div>', {}]); + $location.path('/foo'); + $rootScope.$digest(); + + expect($route.current.controller).toBe('MyCtrl'); + expect(MyCtrl).toHaveBeenCalledWith(element.contents().scope()); + }); + }); + + it('should load content via xhr when route changes', function() { module(function($routeProvider) { $routeProvider.when('/foo', {template: 'myUrl1'}); |
