我试图在ui-router reslove中解析控制器和服务,如下所示
控制器是:' js / app / dashboard / dashboardService.js', 服务是:' js / app / dashboard / dashboard.Controller.js'
.state('dashboards.sample', {
url: "/outlook",
templateUrl: "views/Dashboard/sample.html",
data: { pageTitle: 'Outlook view', specialClass: 'fixed-sidebar' },
controller: 'productsController',
controllerAs: 'pd',
resolve: {
loadPlugin: function ($ocLazyLoad) {
return $ocLazyLoad.load([
{
name: 'ProductModule',
files: ['js/app/dashboard/dashboardService.js', 'js/app/dashboard/dashboard.Controller.js']
}
]);
}
}
})
这个问题是控制器在服务之前被加载(有时它会反过来)。那么有没有办法嵌套解决这个问题,即首先加载服务而不是控制器。
通常在控制台中抛出的错误
angular.js:38 Uncaught Error: [$injector:nomod] http://errors.angularjs.org/1.5.0/$injector/nomod?p0=ProductModule(anonymous function) @ angular.js:38(anonymous function) @ angular.js:2015b @ angular.js:1939(anonymous function) @ angular.js:2013(anonymous function) @ dashboardService.js:2
angular.js:13236 Error: [$injector:unpr] http://errors.angularjs.org/1.5.0/$injector/unpr?p0=dashboardServiceProvider%20%3C-NaNashboardService%20%3C-%20productsController
at Error (native)
at http://localhost:8012/js/angular/angular.min.js:6:416
at http://localhost:8012/js/angular/angular.min.js:43:7
at Object.d [as get] (http://localhost:8012/js/angular/angular.min.js:40:270)
at http://localhost:8012/js/angular/angular.min.js:43:69
at d (http://localhost:8012/js/angular/angular.min.js:40:270)
at e (http://localhost:8012/js/angular/angular.min.js:41:1)
at Object.instantiate (http://localhost:8012/js/angular/angular.min.js:41:364)
at http://localhost:8012/js/angular/angular.min.js:87:42
at http://localhost:8012/js/ui-router/angular-ui-router.min.js:7:23333
答案 0 :(得分:0)
我这样做是为了顺序加载文件(即//Convert bitmap to drawable
Drawable drawable = new BitmapDrawable(context.getResources(), bitmap);
)。通过这种方式,服务文件将在控制器中使用之前加载。
serie: true,