2

I have a form in my component, and I would like access to input value attribute from my model in controller.

I can access to the firs, because I give the value, but second is calculated by pipe and I.can't get this value.

Component

<form class="formQuote" #newQuote="ngForm" (ngSubmit)="onSubmit(newQuote)">

 <input type="number" name="quantity" class="form-control" #quantity="ngModel" [(ngModel)]="cart.quantity" placeholder="1">
 <input name="precio" #price="ngModel" [(ngModel)]="cart.price" [disabled]="true" value="{{serviceSelected | calcPrice : quote.kg : cart.quantity : true | currency:'MXN':symbol:'1.2-2'}}">
 <button mat-stroked-button color="primary" type="submit">Add</button>

</form>

Controller

export class TableQuoteComponent implements OnInit {

  cart: ShoppingCart = {};

  constructor(private cartService: PrepayService) { }

  ngOnInit() {

  }
  onSubmit(newObj) {
    this.cart = newObj.value;
    this.cartService.addData({...this.cart});
  }

}
  • Check this out https://stackoverflow.com/a/39643180/2630817 – Just code Jan 15 '19 at 03:38
  • You probably want to check out this post [accessing ngForm](https://stackoverflow.com/questions/37093432/angular-2-template-driven-form-access-ngform-in-component) and then the docs on ngForm. – Joe Jan 15 '19 at 03:55

0 Answers0