简体   繁体   English

AngularJS中的路线

[英]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. 我是AngularJS的新手,遇到了一些障碍,想知道是否有人可以将我推向正确的方向。

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: 我将我创建的模板用作应用程序的路由系统的一部分,然后使用生成的URL动态生成带有从控制器中对象的特定部分获取的ID的url,这是一个示例:

{
   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: 如您所见,我对象的第一部分称为“ id”,并在$ routeProvider中将其配置为:

$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). (guides.html可以正常工作,但help.html当前恢复为空白)。

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. 当我将鼠标悬停在生成的列表中的链接上时,我可以看到id正在通过并显示在页面底部,但是链接转到一个空白模板。 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. 我知道我必须添加一个控制器,然后将ID粘贴到$ routeParams,但是,当我在AngularJS Docs中使用phoneApp示例流程时,它似乎不起作用。

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? 如果您使用的是Android手机,则不必从根目录指定目录路径吗? (not like appeared to have done for windows ( pdf: 'assets/files/getting_started.pdf')) (似乎不适合Windows(pdf:'assets / files / getting_started.pdf'))

Sorry I'm fairly new to this myself. 抱歉,我本人还很陌生。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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