Within my application, I have successfully implemented a list view and a detailed view for individual list items. Users are able to access the detailed view by clicking on a list entry. Now, my goal is to include links in emails that will directly lead users to specific item details.
I have been exploring the use of ngRoute for this functionality, but unfortunately, it is not behaving as expected - in fact, it does not appear to be working at all. The alert()
function I included is never triggered.
The following section highlights the relevant portion of my controller:
var myController = angular.module('myProject.controllers', ['ngRoute']);
myController.config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {
$routeProvider.when('/show/:itemId', {
templateUrl: 'item-details.html',
controller: 'MyController'
});
$locationProvider.html5Mode(true);
}]);
myController.controller('MyController', ['$scope', '$routeParams', function($scope, $routeParams) {
/** Other stuff... */
$scope.$on('$routeChangeSuccess', function() {
// Ensure $routeParams has data
alert("itemId: " + $routeParams.itemId);
if ($routeParams.item) {
myFunction($routeParams.itemId);
}
});
}]);
I attempted accessing my page using both
http://www.example.com/index.html#/show/123
as well as
http://www.example.com/show/123
but unfortunately, neither method proved successful. Any insights into what may have gone awry would be greatly appreciated.