This repository was archived by the owner on Dec 24, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -5,12 +5,17 @@ angular.module('myApp.view1', ['ngRoute'])
5
5
. config ( [ '$routeProvider' , function ( $routeProvider ) {
6
6
$routeProvider . when ( '/view1' , {
7
7
templateUrl : 'view1/view1.html' ,
8
- controller : 'View1Ctrl'
8
+ controller : 'View1Ctrl' ,
9
+ resolve : {
10
+ user : function ( $http ) {
11
+ return $http . get ( 'backend/user.php' ) . then ( function ( user ) {
12
+ return user . data ;
13
+ } ) ;
14
+ }
15
+ }
9
16
} ) ;
10
17
} ] )
11
18
12
- . controller ( 'View1Ctrl' , function ( $http , $scope ) {
13
- $http . get ( 'backend/user.php' ) . success ( function ( user ) {
14
- $scope . user = user ;
15
- } ) ;
19
+ . controller ( 'View1Ctrl' , function ( $scope , user ) {
20
+ $scope . user = user ;
16
21
} ) ;
Original file line number Diff line number Diff line change @@ -9,7 +9,8 @@ describe('myApp.view1 module', function() {
9
9
it ( 'should ....' , inject ( function ( $rootScope , $controller ) {
10
10
//spec body
11
11
var scope = $rootScope . $new ( ) ;
12
- var view1Ctrl = $controller ( 'View1Ctrl' , { $scope : scope } ) ;
12
+ var user = { 'id' : "foo" } ;
13
+ var view1Ctrl = $controller ( 'View1Ctrl' , { $scope : scope , user : user } ) ;
13
14
expect ( view1Ctrl ) . toBeDefined ( ) ;
14
15
} ) ) ;
15
16
You can’t perform that action at this time.
0 commit comments