命名为ui-view =' main'没有在角度4.x中显示任何内容

时间:2017-10-08 07:16:32

标签: angularjs angular-ui-router

我正以角度4.x运行UI Router。下面的代码没有呈现任何内容,我也没有收到任何错误消息。但是当我更改为$ default作为视图名称时,我正在获取该页面。请建议我。

<app-root>
<ui-view name='main'></ui-view>
</app-root>

下面是角度状态定义,

export const appState = {
name: 'app',
views : { 
  main : { 
  component: AppComponent 
  }
}    
};

1 个答案:

答案 0 :(得分:0)

When Angular application bootstrap's, it wipes out the inner content of app-root(root) component. What ever you put inside root component will appear until Angular application bootstrap. Generally this place has been used to add Splash screen, loader to show initial loading.

To see your ui-view to replace via ui-router configuration, you should add ui-view inside app-root component HTML.

@Component({
  selector: 'app-root',
  template: `<ui-view name='main'></ui-view>`
})
export AppRootComponent {


}