zl程序教程

您现在的位置是:首页 >  前端

当前栏目

Angular ctorParameters,decorator等元数据,包含在ActivatedRouteSnapshot数据结构里

Angular数据数据结构 包含 Decorator
2023-09-14 09:04:03 时间

顾名思义,这个变量包含了一个Angular Component构造函数的参数。看一个例子:

我有一个PageLayoutComponent:构造函数有一个参数pageLayoutService,类型为PageLayoutService:

ctorParameters的值,是这个函数的返回值,一个数组,里面包含唯一一个元素:

这个Component的decorator:

@Component({
  selector: 'cx-page-layout',
  templateUrl: './page-layout.component.html',
  changeDetection: ChangeDetectionStrategy.OnPush,
})

一个set属性,加了@Input的注解:


factory指向的是Component的构造函数:

function location:点击之后能进到Component的源代码位置:

Scopes:能查看闭包信息

加了@Input注解的属性:


在routeConfig参数里,能看到每个路由路径的字符串,和对应应该打开的Angular Component:

更多Jerry的原创文章,尽在:“汪子熙”: