小编Ant*_*ony的帖子

AbstractControl 类型不可分配给 FormGroup 类型

我有一个充满实例的FormGroup控件FormArrayFormGroup

  someForm = this.fb.group({
    days: this.fb.array([
      this.fb.group({
        description: ['']
      })
    ])
  })
Run Code Online (Sandbox Code Playgroud)

另外,我有一个用于该数组的吸气剂

  get days(): FormArray {
    return this.someForm.get('days') as FormArray;
  }
Run Code Online (Sandbox Code Playgroud)

当我尝试迭代FormArray并将其分配给[formGroup]指令时,如本文所示

 <div *ngFor="let day of days.controls">
  <ng-container [formGroup]="day">
    ...
Run Code Online (Sandbox Code Playgroud)

我越来越

error TS2740: Type 'AbstractControl' is missing the following properties from type 'FormGroup': controls, registerControl, addControl, removeControl, and 3 more.
Run Code Online (Sandbox Code Playgroud)

angular angular-reactive-forms

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

img 标签如何通过 cors 标头获取内容

为什么,当我使用 fetch 从带有禁用响应 CORS 标头的服务器加载数据时,我预计会收到一个错误:
Failed to load http://www.imgworlds.com/wp-content/uploads/2015/12/18-CONTACTUS-HEADER.jpg: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:63343' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
但是显示了来自 img 标签的图像

<script>
    fetch('http://www.imgworlds.com/wp-content/uploads/2015/12/18-CONTACTUS-HEADER.jpg').then(console.log);
</script>
<img src="http://www.imgworlds.com/wp-content/uploads/2015/12/18-CONTACTUS-HEADER.jpg">
Run Code Online (Sandbox Code Playgroud)

html http http-headers cors

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

如何为“tsc-watch”注册“tsconfig-paths”?

我正在尝试为运行它的应用程序设置相对路径tsc-watch。但是当我尝试从功能文件夹访问共享文件夹中的枚举时,我收到“错误:找不到模块”。运行应用程序工作正常。我如何使用with ?ts-nodetsconfig-pathstsc-watch

这是我的项目的仓库:https ://github.com/Nako68l/nestjs-task-management

tsc nestjs tsconfig-paths

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

vscode Service Worker 接口对象自动完成

为什么 vscode 看不到 Service Worker 接口对象?
\n缺乏自动完成
\n 虽然浏览器显示它们仍然存在
\n存在登录在浏览器中的对象
\n如何解决此问题?

\n\n

整个服务人员代码:

\n\n
self.addEventListener(\'install\', event => {\n    console.log(\'V1 installing\xe2\x80\xa6\');\n    event.waitUntil(\n        caches.open(\'static-v1\').then(cache => cache.add(\'/cat.png\'))\n    );\n});\n\nself.addEventListener(\'activate\', event => {\n    console.log(\'V1 now ready to handle fetches!\');\n});\n\nself.addEventListener(\'fetch\', event => {\n    const url = new URL(event.request.url);\n    if (url.origin == location.origin && url.pathname == \'/dog.png\') {\n        event.respondWith(caches.match(\'/cat.png\'));\n    }\n\n    if (url.origin == location.origin) {\n        console.log("Clients object: ", clients);\n    }\n});\n
Run Code Online (Sandbox Code Playgroud)\n

javascript service-worker visual-studio-code

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