Angular:无法从库中加载组件:无法读取 null 的属性(读取“11”)

Angular : unable to load component from library : Cannot read properties of null (reading '11')

在我的 Angular 应用下

我正在尝试加载从本地 angular 库

获取的组件

我的组件(来自库)如下所示:

import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'lib-ada-headband-lib',
  templateUrl: './ada-headband-lib.component.html',
  styleUrls: ['./ada-headband-lib.component.scss']
})
export class AdaHeadbandLibComponent implements OnInit {

  constructor() { }

  ngOnInit(): void {
  }

}

它的视图 html 看起来像这样:

<span>
  ada-headband-lib works!
</span>

在我的校长Angular项目下

我通过将库作为模块导入 app.module 从库中获取这个

然后,我将它放在我的 app.component.html 下,如下所示:

  <section>
    <lib-ada-headband-lib></lib-ada-headband-lib>
  </section>

但加载失败并抛出此错误:

core.js:6479 ERROR TypeError: Cannot read properties of null (reading '11')
    at Object.Jv (core.js:14869:1)
    at template (ada-headband-lib.component.ts:8:14)
    at bc (core.js:9599:1)
    at id (core.js:9402:1)
    at Za (core.js:10683:1)
    at core.js:9267:1
    at id (core.js:9427:1)
    at L0.createEmbeddedView (core.js:23026:1)
    at F0.createEmbeddedView (core.js:23157:1)
    at Fn._updateView (common.js:3463:1)

好像不是很明显,我该如何调整??

解决方案是将选项 "preserveSymlinks":true 添加到 angular.json

"projects": {
    "myapp": {
      "root": "",
      "sourceRoot": "src",
      "projectType": "application",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "preserveSymlinks": true,
       ...