繁体   English   中英

无法使用 NgModel 将带有附件的 SharePoint 列表项从 Angular 添加到 ASP.NET Core Web API

[英]Unable to add SharePoint list item with attachment from Angular to ASP.NET Core Web API using NgModel

我已将带有附件的 SharePoint 列表项从 Angular 添加到 ASP.NET Core Web API。 我在 Angular 应用程序中使用了 FormControl。

我参考了下面的链接, 如何将文件从 Angular 上传到 ASP.NET Core Web API

现在,我需要在 Angular 应用程序中使用 NgModel 而不是 FormControl 来执行相同的操作。

任何人都可以帮助我吗?

谢谢

我使用此链接的示例, 如何将文件从 Angular 上传到 ASP.NET Core Web API 我想一定是这样的:

html

<form (ngSubmit)="onSubmit()">
    <div>
        <label for="Name">
            Blog Name
        </label>
        <input type="text" name="Name" [(ngModel)]="Name">
    </div>

    <div>
        <label for="TileImage">
            Tile Image
        </label>
        <input type="file" name="TileImage" [(ngModel)]="TileImage">
    </div>

    <button type="submit">Create Blog</button>

</form>

打字稿

import { Component, OnInit } from '@angular/core';
import { FormControl } from '@angular/forms';
import { BlogService } from '../blog-services/blog.service';

@Component({
  selector: 'app-new-blog',
  templateUrl: './new-blog.component.html',
  styleUrls: ['./new-blog.component.css']
})
export class NewBlogComponent implements OnInit {
  public Name = '';
  public TileImage= '';
  constructor(private blogService: BlogService) { }

  ngOnInit() {}

  onSubmit() {
    this.blogService.postBlog({Name:this.Name,TileImage:this.TileImage});
    this.Name='';
    this.TileImage='';
  }

}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM