【发布时间】:2016-09-09 20:37:37
【问题描述】:
我正在尝试使用 angular2 和路由器创建 Plunkr。我实际上在这里工作:http://plnkr.co/edit/mU0iS0g68G6vEdAokSNd?p=preview
@Component({
selector: 'my-app',
directives: [ROUTER_DIRECTIVES],
providers: [ROUTER_PROVIDERS]
template: '<h1>My First Angular 2 App</h1><br/><router-outlet></router-outlet>'
})
@Routes([
{path:'/page-one',component:PageOneComponent },
{path:'/page-two',component:PageTwoComponent }
{path:'*',component:PageOneComponent }
])
export class AppComponent {
constructor(public router:Router){
}
}
我的问题是,当我在我的机器上运行我的应用程序时,当我更改路由(例如更改为 http://localhost/page-one 之类的东西)时,浏览器中的 URL 会发生变化,但在 plunkr 中,浏览器中的 URL 不会在我更改时更改改变路线 - 它只是保持相同的 plunkr.co/edic/blahblahblah。有没有办法查看/编辑/控制使用路由器的应用程序在 plunkr 中看到的“url”?
更新
为了更好地了解我想要完成的工作,我尝试按照本期的要求使用 plunkr 重现路由器的错误:https://github.com/angular/angular/issues/8603#issuecomment-218953090
【问题讨论】:
-
比如可以使用location.path()plnkr.co/edit/fUZ08lLfP7UGdp07KxN8?p=preview
-
@yurzui...这仍然没有任何意义。不工作!
-
@Tucker take.ms/EKfMe
标签: angular url-routing plunker