小编Yas*_*yan的帖子

带有纱线的角CLI

如何将Angular Cli v6.0.3的程序包管理器更改为yarn?我试过了:

ng set --global packageManager=yarn
Run Code Online (Sandbox Code Playgroud)

但是Angular说:

不赞成使用get / set,而推荐使用config命令。

yarnpkg angular

9
推荐指数
3
解决办法
2531
查看次数

Angular 6 ActivatedRoute 网址

在这里,我有 MyComponent,其中路由器根据路由加载不同的其他组件,我想在标头组件中获取完整的当前路由,但 ActivatedRoute.url 仅显示 {path: "d"} 而不是完整路径,或路径(我需要)。您对如何在标题组件中获取加载的路由有任何想法。

我的component.component.html

<app-header></app-header>
<router-outlet></router-outlet>
Run Code Online (Sandbox Code Playgroud)

header.component.ts

 ...
constructor(private route: ActivatedRoute) {}
ngOnInit() {
    this.route.url.subscribe(url=>console.log(url));
}
Run Code Online (Sandbox Code Playgroud)

my-module-routing.module.ts

    {
    path: 'd',
    component: MyComponent,
    children: [
        {
            path: 'discover',
            component: DiscoverComponent
        },
        {
            path: 'book/:id',
            component: BookPageComponent
        },
        {
            path: 'search',
            component: SearchPageComponent
        }]
    }
Run Code Online (Sandbox Code Playgroud)

在 d/search console.logs 上时

[UrlSegment]
0: UrlSegment
parameterMap: ParamsAsMap
parameters: {}
path: "d"
__proto__: Object
length: 1
__proto__: Array(0)
Run Code Online (Sandbox Code Playgroud)

angular

1
推荐指数
1
解决办法
1万
查看次数

标签 统计

angular ×2

yarnpkg ×1