Plunkr + Angular2 +路由器+浏览器URL更改

时间:2016-05-13 15:08:53

标签: angular url-routing plunker

我正在尝试使用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){

  }
}

我的问题是,当我在我的机器上运行我的应用程序时,当我更改路由时,URL将在浏览器中更改(例如,更改为http://localhost/page-one),但在plunkr中,浏览器中的URL永远不会更改当我改变路线时 - 它只是保持相同的plunkr.co/edic/blahblahblah。有没有办法查看/编辑/控制使用路由器的应用程序在plunkr中看到的'url'?

更新

为了更好地了解我想要实现的目标,我尝试使用此问题中的请求使用plunkr重现路由器的错误:https://github.com/angular/angular/issues/8603#issuecomment-218953090

1 个答案:

答案 0 :(得分:2)

在一个弹药内部,你必须在外部窗口打开弹药:

enter image description here

然后,在一个窗口中打开plunker,它将显示您期望的URL更改。见下文:

enter image description here