angularjs - Angular route resolve not passing to controller -
for reason whatever cannot data controller no matter do, keep getting error
error: [$injector:unpr] unknown provider: initdataprovider <- initdata <- packingscancontroller
first file
var application = angular.module('reporterapplication', ['ngroute']); application.config(['$routeprovider', '$interpolateprovider', function($routeprovider, $interpolateprovider) { $interpolateprovider.startsymbol('<%'); $interpolateprovider.endsymbol('%>'); $routeprovider .when('/packing/scan.html', { controller: 'packingscancontroller', templateurl: 'packing/scan.html', resolve: { initdata : function () { return "shite"; } } }) etc more code
second file
application.controller('packingscancontroller', ['$scope', '$http', 'initdata', function($scope, $http, initdata) { var packer = this; $scope.packedtoday = initdata;
the posted code right, injecting initdata
resolve route block. using explicit ngcontroller
in route template. don't want it, , of course in case there no initdata
service available results in error getting.
solution simple: remove
ng-controller="packingscancontroller"
from packing/scan.html
template , work fine.
explicit controller binding not needed in case since template bound controller instance created behind scene $route
service, necessary dependencies injected.
Comments
Post a Comment