0

I have added the SharePoint list item with an attachment from Angular to ASP.NET Core Web API. I have used FormControl in the Angular application.

I have referred below link, How to Upload File from Angular to ASP.NET Core Web API

Now, I need to perform the same using NgModel instead of FormControl in the Angular application.

Can anyone help me with the same?

Thanks

1 Answer 1

0

i use example of this link, How to Upload File from Angular to ASP.NET Core Web API. i think must be like this :

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>

typescript

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='';
  }

}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.