Last active
August 29, 2015 14:03
-
-
Save HAKASHUN/a441652aa985cd8e62b5 to your computer and use it in GitHub Desktop.
肥大化した$routeProvider定義を解決する
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// gacha module | |
var Gacha = angular.module('gacha', []); | |
var config = function($routeProvider, $injector) { | |
$routeProvider. | |
when('/', { | |
templateUrl: 'templates/gacha/index.html', | |
controller: 'IndexCtrl', | |
controllerAs: 'ctrl', | |
resolve: $injector.get('IndexResolver') | |
}). | |
when('/normal', { | |
templateUrl: 'templates/gacha/normal.html', | |
controller: 'NormalCtrl', | |
controllerAs: 'ctrl', | |
resolve: $injector.get('NormalResolver') | |
}). | |
when('/special', { | |
templateUrl: 'templates/gacha/special.html', | |
controller: 'SpecialCtrl', | |
controllerAs: 'ctrl', | |
resolve: $injector.get('SpecialResolver') | |
}). | |
otherwise({ | |
redirectTo: '/' | |
}); | |
}; | |
config.$inject = ['$routeProvider', '$injector']; | |
// configuration for this module | |
Gacha.config(config); | |
var IndexResolver = { | |
data: ['userService', function(userService){ | |
return userService.get(); | |
}] | |
}; | |
var NormalResolver = { | |
data: ['userService', function(userService){ | |
return userService.get(); | |
}] | |
}; | |
var SpecialResolver = { | |
data: ['userService', function(userService){ | |
return userService.get(); | |
}] | |
}; | |
//resolver | |
Gacha.constant('IndexResolver', IndexResolver); | |
Gacha.constant('NormalResolver', NormalResolver); | |
Gacha.constant('SpecialResolver', SpecialResolver); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment