admin管理员组文章数量:1128537
I have two angular components: Program, and MitProgram, each with their own URLs
/landsstaevne/program /landsstaevne/program/mit-program
My problem is that I can't directly go to the MitProgram URL (or by refreshing the page), only when going to the Program page first and visiting it from there.
My Angular routing logic is as follows:
.config(function ($locationProvider) {
$locationProvider.html5Mode(true);
$locationProvider.hashPrefix('');
})
.value('$routerRootComponent', 'landsstaevneProgram')
ponent('landsstaevneProgram', {
templateUrl: '/app.html',
$routeConfig: [
{ path: '/landsstaevne/program/mit-program', name: 'MitProgram', component: 'mitProgram' },
{ path: '/landsstaevne/program', name: 'Program', component: 'program', useAsDefault: true }
],
Note: This is using AngularJS
When i go to MitProgram from the Program component, the URL changes as well and the component is displayed on the page. However, when i refresh said page, or enter the URL into a new tab, a 404 page is shown instead.
I'm wondering why the Angular router is not picking up this URL and routing me to the correct component as specified in the route config.
Navigation to the MitProgram component from the Program component:
<div
ng-link="['MitProgram']"
title="Mit program"
class="btn btn-link-program icon icon-custom-heart"
>
Mit program
</div>
I have two angular components: Program, and MitProgram, each with their own URLs
/landsstaevne/program /landsstaevne/program/mit-program
My problem is that I can't directly go to the MitProgram URL (or by refreshing the page), only when going to the Program page first and visiting it from there.
My Angular routing logic is as follows:
.config(function ($locationProvider) {
$locationProvider.html5Mode(true);
$locationProvider.hashPrefix('');
})
.value('$routerRootComponent', 'landsstaevneProgram')
.component('landsstaevneProgram', {
templateUrl: '/app.html',
$routeConfig: [
{ path: '/landsstaevne/program/mit-program', name: 'MitProgram', component: 'mitProgram' },
{ path: '/landsstaevne/program', name: 'Program', component: 'program', useAsDefault: true }
],
Note: This is using AngularJS
When i go to MitProgram from the Program component, the URL changes as well and the component is displayed on the page. However, when i refresh said page, or enter the URL into a new tab, a 404 page is shown instead.
I'm wondering why the Angular router is not picking up this URL and routing me to the correct component as specified in the route config.
Navigation to the MitProgram component from the Program component:
<div
ng-link="['MitProgram']"
title="Mit program"
class="btn btn-link-program icon icon-custom-heart"
>
Mit program
</div>
Share
Improve this question
edited Jan 8 at 14:02
AVJT82
73.3k25 gold badges145 silver badges170 bronze badges
asked Jan 8 at 13:12
LethLeth
1,0593 gold badges16 silver badges49 bronze badges
2
- please share the link you use for navigation – Naren Murali Commented Jan 8 at 13:20
- I've added the code for navigation to the question body – Leth Commented Jan 8 at 13:26
1 Answer
Reset to default 0Because your server knows nothing about your url. When your server encounters this url, it does not route it to your index page, where then angular can bootstrap your application.
本文标签:
版权声明:本文标题:javascript - Going directly to URL or refreshing page with URL does not invoke the Angular router - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736725570a1949707.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论