簡體   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