Adding subdirectories to Angular route
I am currently trying to organise my project more neatly, so that I can
have a projects folder, for (you guessed it) projects!
In the app.js file, I set up my route like this:
.when('/contact', {
templateUrl: 'views/contact.html',
controller: 'MainCtrl'
})
This style of routing works just fine, but when I put a template file in a
subfolder, it stops working:
.when('projects/dublin-bus', {
templateUrl: 'views/projects/dublin-bus.html',
controller: 'MainCtrl'
})
The data is just a dummy JSON object, that fills the template in the view:
{
title: 'Dublin Bus',
url: '#/projects/dublin-bus'
}
<li ng-click="toggleMenu()" ng-repeat="project in projects"><a
ng-href="{{project.url}}">{{project.title}}</a></li>
This code doesn't produce any errors in the browser, or render incorrect
HTML:
Do I need to declare this route parameter somewhere?
No comments:
Post a Comment