Thanks Matt! I had the same exact problem.
On Monday, June 17, 2013 2:55:56 PM UTC-7, Matt Madhavan wrote:
>
> Hello,
> Sorry please ignore this email There was a bug in my template. I had the
> controller defined there for testing and it was causing the controller to
> be invoked twice - the second invocation from the hardcoded controller
> from the template which was which was missing the resolve dependency!
>
> Thanks
> Matt'M
>
>
> On Monday, June 17, 2013 4:00:57 PM UTC-5, Matt Madhavan wrote:
>>
>> Hello,
>> My route provider correctly resolves a dependency and injects it to the
>> Controller as expected. The controller receives the correct values in the
>> injected value. How ever later I am getting the Error: Unknown Provided for
>> the dependency that was injected correctly! Any ideas please. Been stuck on
>> this for a day now! :(
>>
>> *My Router/Controller configuraion:*
>>
>> var app = angular.module('claimsgui', ['claimsgui.services', 'ngGrid']);
>>> app.config (['$routeProvider', function($routeProvider) {
>>> $routeProvider.
>>> when('/claimsgui',{
>>> controller: 'SearchCtrl',
>>> templateUrl: 'partials/simple-search.html'}).
>>> when('/claimsgui/claimsummary/:groupId', {
>>> controller: 'ClaimSummaryCtrl',
>>> resolve: {
>>> *members*: function(MembersLoader) {
>>> return MembersLoader();
>>> }
>>> },
>>> templateUrl: 'partials/claim-summary.html'}).
>>> otherwise({redirectTo: '/claimsgui'});
>>> }]);
>>>
>>> app.controller('SearchCtrl', ['$scope', '$location',
>>> function($scope, $location) {
>>> $scope.groupId;
>>> $scope.submit = function() {
>>> $location.path('/claimsgui/claimsummary/' + $scope.groupId);
>>> }
>>> }]);
>>>
>>> app.controller('ClaimSummaryCtrl', ['$scope', '$location', '*members*',
>>> function($scope, $location, members) {
>>> console.log ('ClaimSummaryCtrl - The number of Loaded Members are :
>>> ' + members.length);
>>> $scope.members = members;
>>>
>>> }]);
>>>
>>
>> The controller prints 2 members as expected ( and the values are correct
>> - I checked them in the debugger).
>> After the controller exists I am getting the following error:
>>
>> Error: Unknown provider: membersProvider <- members at Error
>>> (<anonymous>) at
>>> http://localhost:8000/app/lib/angular/angular.js:2696:15
>>> <http://localhost:8000/app/lib/angular/angular.js> at Object.getService
>>> [as get] (http://localhost:8000/app/lib/angular/angular.js:2824:39
>>> <http://localhost:8000/app/lib/angular/angular.js>) at
>>> http://localhost:8000/app/lib/angular/angular.js:2701:45
>>> <http://localhost:8000/app/lib/angular/angular.js> at getService (
>>> http://localhost:8000/app/lib/angular/angular.js:2824:39
>>> <http://localhost:8000/app/lib/angular/angular.js>) at invoke (
>>> http://localhost:8000/app/lib/angular/angular.js:2842:13
>>> <http://localhost:8000/app/lib/angular/angular.js>) at
>>> Object.instantiate (
>>> http://localhost:8000/app/lib/angular/angular.js:2874:23
>>> <http://localhost:8000/app/lib/angular/angular.js>) at $get (
>>> http://localhost:8000/app/lib/angular/angular.js:4759:24
>>> <http://localhost:8000/app/lib/angular/angular.js>) at $get.i (
>>> http://localhost:8000/app/lib/angular/angular.js:4338:17
>>> <http://localhost:8000/app/lib/angular/angular.js>) at forEach (
>>> http://localhost:8000/app/lib/angular/angular.js:138:20
>>> <http://localhost:8000/app/lib/angular/angular.js>)
>>
>>
>>
>> *My Service is as follows:*
>>
>>> services.factory ('*MembersLoader'*, ['Members', '$route', '$q',
>>> function(Members, $route, $q) {
>>> return function() {
>>> var delay = $q.defer();
>>> Members.query ({groupId: $route.current.params.groupId},
>>> function(members) {
>>> delay.resolve(members);
>>> }, function() {
>>> delay.reject ('Unable to fetch recipe ' + params);
>>> });
>>> return delay.promise;
>>> };
>>> }]);
>>
>>
>> Which works fine and the promise is resolved fine!
>>
>> Any ideas please? I appreciate in advance!
>>
>> Thanks
>> Matt'M
>>
>>
>>
>>
>>
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.