javascript - Angular UI Router resolve throwing provider error -
i seem having issue angular ui router , trying add resolve state. weird thing is, have in place , works fine.
i'm separating code out different component areas, code structure this:
/app /component-dashboard index.js /controllers dashboardctrl.js /component-chart-1 index.js /controllers chart1ctrl.js
for example have root dashboard , works fine:
// index.js angular.module('az-ci') .config([ '$stateprovider', function($stateprovider) { $stateprovider .state('dashboard', { templateurl: '/app/ci-dashboard/templates/dashboard.html', url: '/', controller: 'dashboardctrl', resolve: { chartlist: function() { return [{ name: 'chart 1', state: 'dashboard.chart1' }]; } } }); } ]); // dashboard ctrl angular.module('az-ci') .controller('dashboardctrl', [ '$scope', '$rootscope', 'chartlist', function($scope, $rootscope, chartlist) { $scope.chartlist = chartlist; } ]);
however in chart component, following error (simplified) code:
// error error: [$injector:unpr] unknown provider: productlistprovider <- productlist // index.js angular.module('az-ci') .config([ '$stateprovider', function($stateprovider) { $stateprovider .state('dashboard.chart1', { templateurl: '/app/ci-chart-1/templates/chart.html', url: '/chart/chart1', controller: 'chart1ctrl', resolve: { productlist: ['csv', '$stateparams', function(csv, $stateparams) { return {}; }] } }); } ]); // chart1ctrl angular.module('az-ci') .controller('chart1ctrl', [ '$scope', '$rootscope', '$state', 'productlist', function($scope, $rootscope, $state, productlist) { $scope.products = productlist; } ]);
the problem had defined controller used in directive created display d3 chart. removing defined controller fixed it.
Comments
Post a Comment