angular - 为什么反射元数据不是 Angular 依赖项?
问题描述
Angular 使用一些修饰构造函数的元数据来进行依赖注入。例如:
@Injectable({
providedIn: 'root',
})
class MyService {}
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
})
export class AppComponent {
constructor(private service: MyService) {} //service will be injected using the type MyService of the param.
}
但是,如果是这样,为什么'reflect-meta-data'
package.json 在生成的角度应用程序中没有依赖关系?如何在运行时获取构造函数的类型注释?
解决方案
推荐阅读
- javascript - JS 国家重定向
- python - 有很多参数的 Python 类
- swift - SwiftUI Shift Picker 文本水平
- html - Google Apps Script GAS 中未返回 HTML 模板
- regex - 使用 IFS 和 REGEXMATCH 失败
- python - Pyspark 无法初始化火花上下文
- css - 为动态数据渲染对齐 CSS 时间线组件
- java - 将 XML 中的不同值插入数据库表
- java - 如何在 REST API 中获取已登录的用户 ID
- python - python SciPy curve_fit with np.exp 返回 pcov = inf