The problem was that I specified controller for productDetail in two places 
- one in routing configuration like this:

mainModule.config(['$routeProvider', function($routeProvider) {
    $routeProvider.when('/products/:productId', {
        templateUrl: 'productDetail.html',
        controller: 'ProductDetailController',
        resolve: productDetailController.resolve
    });
  }]);

and also in template 'productDetail.html' like this:

<div class="row" ng-app="Catalog">
    <div class="col-md-12" ng-controller="productDetailController">
           ...
    </div>
</div>

I found it while creating plunkr example for you. I simply deleted 
ng-controller attribute from template and it works. 

I checked if it works, when controller is defined within template body and 
$routeProvider.when for this route defines only template name and resolve 
variable, but omits controller - it doesn't work that way - I didn't know 
that. Many sources providing examples on how to use route's resolve don't 
clearly say that it should be done that way, but on the other hand they 
clearly say that route controllers can be defined both in route definition 
( only reusability across different templates is mentioned for this method 
) and within template body.

I also fixed my controllers definition and corrected DI arrays ( that 
wasn't the case here, but good to know for future coding ) - much thanks 
here to you for clear explanation, plus examples (!).

-- 
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/groups/opt_out.

Reply via email to