I'm facing an issue with my Angular JS application where the $routeProvider
doesn't load the template in the ng-view section.
I have set up <html data-ng-app="myApp">
and
<section data-ng-view></section
.
The template doesn't load (no XHR request is made), it doesn't redirect to other paths like /#/foo/bar/foo/
, and no errors are thrown.
This is how I've configured it:
angular.module('myApp', ['myAppFilters'])
.config [
'$routeProvider',
($routeProvider) ->
$routeProvider
.when '/:year/:month',
templateUrl: 'partials/detail.html'
controller: DetailCntl
.when '/:user/:year/:month',
templateUrl: 'partials/detail.html'
controller: DetailCntl
.otherwise
redirectTo: '/'
]
Edit: Here's the compiled JavaScript:
angular.module('myApp', ['myAppFilters']).config([
'$routeProvider', function($routeProvider) {
return $routeProvider.when('/:year/:month', {
templateUrl: 'partials/detail.html',
controller: DetailCntl
}).when('/:user/:year/:month', {
templateUrl: 'partials/detail.html',
controller: DetailCntl
}).otherwise({
redirectTo: '/'
});
}
]);
Edit #2: Found a solution on my own:
I had this line in my factories.coffee
file that was overriding the configuration:
angular.module('myApp', []).factory 'api', ($http, $q, $cacheFactory) ->
...
Now I have assigned the configuration to @myApp
and using @myApp.factory 'api', ...
and it's functioning correctly.