Angularjs uiRouter路由从索引工作,但不从主目录工作
在我的角度项目中,我使用uiRouter。在我的应用程序中,我有一个主页、一个注释索引页和注释页。网址分别为:Angularjs uiRouter路由从索引工作,但不从主目录工作,angularjs,angular-ui-router,Angularjs,Angular Ui Router,在我的角度项目中,我使用uiRouter。在我的应用程序中,我有一个主页、一个注释索引页和注释页。网址分别为: // Home page $stateProvider.state('home', { url: '^/', ... }) // Notes index page $stateProvider.state('home.notes', { url: '^/notes/pageno/{pageno:int}', ... }) // Note page $stateProvider.st
// Home page
$stateProvider.state('home', { url: '^/', ... })
// Notes index page
$stateProvider.state('home.notes', { url: '^/notes/pageno/{pageno:int}', ... })
// Note page
$stateProvider.state('home.notes.note', { url: '^/notes/{id:int}', ... })
在主页和notes索引页面的模板中,我有:
<li ng-repeat="note in vm.list">
<a ui-sref="home.notes.note({ id: note.id })">
<h2>{{ ::note.title }}</h2>
{{ ::note.body }}
</a>
</li>
{{::note.title}
{{::note.body}
指向注释页的链接可以从注释索引中工作,但不能从主页中工作。在主页上,它们似乎呈现得很好,当我将鼠标悬停在链接上时,正确的URl会显示在工具提示中,但当我单击时,什么也不会发生。没有记录任何错误。我可能做错了什么?您定义的url对我来说很奇怪。为什么有
{id:int}
?您是否尝试使用名为id
的参数?是的,如文档所示。你定义的url对我来说很奇怪。为什么有{id:int}
?您是否尝试使用名为id
的参数?是的,如文档所示。这方面是有效的。