简体   繁体   中英

consoling angular form output failed

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.

    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);
 }

}

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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