服务不响应表单提交值

问题描述 投票:2回答:1

这是填写并提交表单的read.html。

  <form class="mt-3 text-center" (ngSubmit)="onSubmit()">
              <div class="text-center">
                <input type="text" name="barcode" class="form-control text-center mt-2" [(ngModel)]="barcode" placeholder="Barcode">
              </div>
            </form>

这是我的read.ts,在提交表单后调用服务并返回信息。

 constructor(private ticketlineservice: TicketlineService, 
    private activatedRoute: ActivatedRoute) {
      this.activatedRoute.queryParams.subscribe(params => {
        this.codEspec = params['CodEspec'];
        this.DiaHoraEspecs = params['DiaHoraEspecs'];
    });
     }

  ngOnInit() {

  }

  onSubmit(){      
    console.log(this.barcode,this.codEspec,this.DiaHoraEspecs );
    this.ticketlineservice.CheckTicket(this.barcode, this.codEspec, this.DiaHoraEspecs).subscribe(reads => {
      this.reads = reads[0].Tickets;
      console.log(reads);
  });
}

我正在调用的服务的功能。另外两个参数(codEspec和DiaHoraEspecs)来自之前的网址。

 CheckTicket(barcode, codEspec, diaHoraEspec):Observable<Ticket[]>{
    //get todos os eventos
    return this.http.get<Ticket[]>(`${this.url_node_tickets}${this.barcode}${this.codEspec}${this.diaHoraEspec}`, httpOptions);
  }

问题:在控制台日志中,所有值都显示且正确,但在URL中,条形码不会更改。

angular typescript service
1个回答
1
投票
CheckTicket(barcode, codEspec, diaHoraEspec):Observable<Ticket[]>{
    //get todos os eventos
    return this.http.get<Ticket[]>(`${this.url_node_tickets}${this.barcode}${this.codEspec}${this.diaHoraEspec}`, httpOptions);
  }

${this.barcode}${this.codEspec}${this.diaHoraEspec}

我认为你需要删除那些this(类引用)并使用函数的参数? ${barcode}${codEspec}${diaHoraEspec}

© www.soinside.com 2019 - 2024. All rights reserved.