aboutsummaryrefslogtreecommitdiffstats
path: root/test/directive/ngViewSpec.js
diff options
context:
space:
mode:
authorIgor Minar2012-03-26 13:01:24 -0700
committerIgor Minar2012-03-26 15:23:29 -0700
commitd54dfecb00fba41455536c5ddd55310592fdaf84 (patch)
treefa146933a2056b69c558f8e0bc0d15a315afeaaa /test/directive/ngViewSpec.js
parent4b8d926062eb4d4483555bdbdec4656f585ab40b (diff)
downloadangular.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.js19
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'});