In my Angular app, I am utilizing $routeProvider
for routing purposes. There are 2 routes where I am using the same HTML template and controller.
when('/products, {
templateUrl: 'views/products.html',
controller: 'ProductListCtrl'
}).
when('/myProducts', {
templateUrl: 'views/products.html',
controller: 'ProductListCtrl'
}).
The only variation lies in the data that needs to be displayed. Specifically, for the products
path, I want an AJAX request to myserver:8080/products
, whereas for the myProducts
path, I need to retrieve data from an AJAX request to myserver:8080/products/my
.
Currently, I am using the $location
service to determine the current page (products
or myProducts
) and load the appropriate information.
I am curious if there is a more elegant solution to achieve this. Is it possible to utilize the resolve
method of $routeProvider
?