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'])
55. config ( [ '$routeProvider' , function ( $routeProvider ) {
66 $routeProvider . when ( '/view1' , {
77 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+ }
916 } ) ;
1017} ] )
1118
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 ;
1621} ) ;
Original file line number Diff line number Diff line change @@ -9,7 +9,8 @@ describe('myApp.view1 module', function() {
99 it ( 'should ....' , inject ( function ( $rootScope , $controller ) {
1010 //spec body
1111 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 } ) ;
1314 expect ( view1Ctrl ) . toBeDefined ( ) ;
1415 } ) ) ;
1516
You can’t perform that action at this time.
0 commit comments