angularjs - Angular ui-route resolve injection issue -
i new in angular js , stack problem inject resolve promise controller.
i have next code:
var app = angular.module('app', ['ui.router', 'nganimate', 'ngsanitize', 'ui.bootstrap']) .config(function ($stateprovider, $urlmatcherfactoryprovider, $urlrouterprovider) { $urlmatcherfactoryprovider.caseinsensitive(true); $urlrouterprovider.otherwise('/refuel'); $stateprovider.state('refuels', { url: '/refuel', controller: 'refuelcontroller', controlleras: 'refuelctrl', resolve: { $refuelspumpsresolve: function ($http) { return $http({ url: "http://localhost:60000/refuels/getuserpumps", method: "get" }) } } }) }) .controller('refuelcontroller', function ($refuelspumpsresolve) { var $this = this; this.isopen = true; this.isopen = function () { $this.isopen = !$this.isopen } this.pumpsdata = $refuelspumpsresolve; });
however angular throws 'unknown provider' exception $refuelspumpsresolve in controller. not see problem, more on code taken ui-route tutorial on github. help
try this, declaring injection say, controller:
resolve: { $refuelspumpsresolve: ['$http', function ($http) { return $http({ url: "http://localhost:60000/refuels/getuserpumps", method: "get" }) }] }
Comments
Post a Comment