The created object's ID does not appear to be available in form

0

I'm using Angular with TypeScript and Asp.Net MVC.

I create an object and the MVC controller returns the object to me. I'm getting this object in TypeScript and the object ID automatically goes to the Form via Bind.

When I call the submit method again, it looks like the Form did not receive the Id. This Id will be used to know if I should give a post or a put.

I'm new to technology, can anyone help me?

NOTE: After creating an object, I remain on the screen if the user wants to edit it. Is this the best way to implement?

The method follows:

submit(form){
    this.professor = form.value.htmlProfessor;

    if (this.professor.Id !=""){
      //aqui vou chamar o put
      console.log(this.professor.Id);
    }else{
      this.service.create(this.professor, 
        (response)=> {
          this.professor = response.json(); 
      });        
    }
  }
    
asked by anonymous 08.11.2017 / 18:07

0 answers