简体   繁体   中英

Routes in AngularJS

I'm pretty new to AngularJS and have a little obstacle and wondered if anyone could push me in the right direction.

I am using as part of my routing system for the application a template I have created and then dynamically generate the url with an id taken from specific parts of objects in my controller here is an example:

{
   id: 'started',
   title: 'Get Started',
   image: 'assets/img/enrolment.jpg',
   system: 'eLP',
   pdf: 'assets/files/getting_started.pdf',
   info: 'blah blah blah.'
 },

so as you can see, the first part of my object is called 'id' and I have it configured within my $routeProvider as:

$routeProvider.

            when('/',
                    {
                templateUrl: 'sessions/guides.html',
                controller: 'tutsList'
            }).
            when('sessions/:id',
                    {
                templateUrl: 'sessions/help.html',
                controller: 'tutsList'
            }).
            otherwise({redirectTo:'/'});
});

(guides.html is working, but help.html is coming back blank currently).

When I hover over the links within list that's generated, I can see the id is now coming through and showing up at the bottom of the page, but the link goes through to a blank template. I am aware that I have to add a controller, which then sticks the id to the $routeParams , but, it doesn't seem to work when I use the phoneApp example process in AngularJS Docs.

Any help would be greatly appreciated.

If your using an android phone, don't you have to specify the directory path from the root directory? (not like appeared to have done for windows ( pdf: 'assets/files/getting_started.pdf'))

Sorry I'm fairly new to this myself.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM