Skip to content

Commit caacabe

Browse files
iszakIgorMinar
authored andcommitted
Moved global controllers to module
1 parent 8c620f3 commit caacabe

File tree

3 files changed

+14
-30
lines changed

3 files changed

+14
-30
lines changed

app/js/app.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33

44
// Declare app level module which depends on filters, and services
5-
angular.module('myApp', ['myApp.filters', 'myApp.services', 'myApp.directives']).
5+
angular.module('myApp', ['myApp.filters', 'myApp.services', 'myApp.directives', 'myApp.controllers']).
66
config(['$routeProvider', function($routeProvider) {
7-
$routeProvider.when('/view1', {templateUrl: 'partials/partial1.html', controller: MyCtrl1});
8-
$routeProvider.when('/view2', {templateUrl: 'partials/partial2.html', controller: MyCtrl2});
7+
$routeProvider.when('/view1', {templateUrl: 'partials/partial1.html', controller: 'MyCtrl1'});
8+
$routeProvider.when('/view2', {templateUrl: 'partials/partial2.html', controller: 'MyCtrl2'});
99
$routeProvider.otherwise({redirectTo: '/view1'});
1010
}]);

app/js/controllers.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22

33
/* Controllers */
44

5+
angular.module('myApp.controllers', []).
6+
controller('MyCtrl1', [function() {
57

6-
function MyCtrl1() {}
7-
MyCtrl1.$inject = [];
8+
}])
9+
.controller('MyCtrl2', [function() {
810

9-
10-
function MyCtrl2() {
11-
}
12-
MyCtrl2.$inject = [];
11+
}]);

test/unit/controllersSpec.js

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,15 @@
22

33
/* jasmine specs for controllers go here */
44

5-
describe('MyCtrl1', function(){
6-
var myCtrl1;
5+
describe('controllers', function(){
6+
beforeEach(module('myApp.controllers'));
77

8-
beforeEach(function(){
9-
myCtrl1 = new MyCtrl1();
10-
});
118

12-
13-
it('should ....', function() {
9+
it('should ....', inject(function() {
1410
//spec body
15-
});
16-
});
17-
18-
19-
describe('MyCtrl2', function(){
20-
var myCtrl2;
21-
22-
23-
beforeEach(function(){
24-
myCtrl2 = new MyCtrl2();
25-
});
26-
11+
}));
2712

28-
it('should ....', function() {
13+
it('should ....', inject(function() {
2914
//spec body
30-
});
15+
}));
3116
});

0 commit comments

Comments
 (0)