0

This is my html view in angular:

<div class="container">
  <div class="row">
        <div class="col-md-3">
        </div>
    <div class="col-md-6">
          <div class="jumbotron">

          <h2>Complete your Profile</h2>
          <h5 style="color:royalblue;">Add your updated Resume to get notified by Recruiters</h5>
          <form #ResumeForm="ngForm"
           (ngSubmit)="submitResume(ResumeForm.value)">
              <div class="form-group">
                <label>Resume</label>
                <input type="file" name="resume" id="resume" class="form-control">
              </div>


                <input value="submit" type="submit">

          </form>

          </div>
    </div>
  </div>
</div>

My .ts file is here

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

@Component({
  selector: 'app-candidate-reg-complete',
  templateUrl: './candidate-reg-complete.component.html',
  styleUrls: ['./candidate-reg-complete.component.css']
})
export class CandidateRegCompleteComponent implements OnInit {

  constructor() { }

  ngOnInit() {
  }
  submitResume=function(user){
   console.log(user);
 }

}

But the console screen shows only object{}. No form content is shown. I am trying to take file input. Can anyone help me?

Thanks in advance.

pranavyoyo
  • 75
  • 1
  • 6
  • 1
    https://stackoverflow.com/questions/35399617/angular-2-file-upload-from-input-type-file – yurzui Jun 08 '17 at 16:49
  • Your `submitResume` function definition should instead be written as `submitResume(user) {`. There's no reason to assign it to a function like that. – Adam Jun 08 '17 at 16:50

2 Answers2

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

@Component({
  selector: 'app-candidate-reg-complete',
  templateUrl: './candidate-reg-complete.component.html',
  styleUrls: ['./candidate-reg-complete.component.css']
})
export class CandidateRegCompleteComponent implements OnInit {

  constructor() { }

  ngOnInit() {
  }
  submitResume(user){
   console.log(user);
 }

}
Praneeth Reddy
  • 424
  • 3
  • 7
0

Put your submitResume(value) function outside ngOnInit. It will be called from the html.

submitResume(value){
   console.log(value);
}