4

My app component (an Angular 2 component, downgraded for index.html) contains this:

  <router-outlet></router-outlet>
  <div ng-view></div>

This is just like it says to do in "Dividing routes between Angular and AngularJS" https://angular.io/docs/ts/latest/guide/upgrade.html#!#adding-the-angular-router-and-bootstrap

But the ng-view isn't picking up any AngularJS routes.

How would ng-view work in an Angular 2 template anyway? How am I supposed to be able to use both types of routers at the same time?

<router-outlet></router-outlet> isn't working either -- this html just shows up on the page statically as-is.

I have <base href="/"> and the javascript console has no errors in it.

Google, message me :) who/ajxtaylor

4

1 回答 1

2

这让我更接近正确的方向,但它仍然无法正常工作。

<router-outlet>没有工作,因为我缺少引导数组中的顶级应用程序组件:

@NgModule({
  bootstrap: [
    AppComponent,
  ],
})
export class AppModule {
  ngDoBootstrap() {}
}

https://angular.io/docs/ts/latest/guide/upgrade.html#!#dividing-routes-between-angular-and-angularjs

提交了关于缺少错误消息的 GitHub 问题:https ://github.com/angular/angular/issues/14572

我不知道 Angular AppComponent 是否应该调用 downgradeComponent ,如果是,index.html 是否应该使用 AngularJS 选择器或 Angular 选择器。

于 2017-02-18T02:30:04.787 回答