Gets an unknown provider when the service is injected into the child state resolution function. But if a solution is defined in the parent state, it just works. The following are sample code:
I defined a service module
angular.module('services', []) .factory('myService', function() {
and initialize the application
var app = angular.module('app', ['services', 'ui.router']); app.config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) { $stateProvider.state('wizard', { url: '/wizard', abstract: true }) .state('wizard.step1', { url: '/step1', templateUrl: ... , resolve: { name: function(myService) {
I got an error An unknown provider complaining about myService in wizard.step1 solution. But if I add a random solution in the parent state, for example
$stateProvider.state('wizard', { url: '/wizard', abstract: true, resolve: { a: function() { return 1; } } })
then it works without errors. I wonder what is going on here?
source share