Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

107
Views
Las opciones de campo de formulario angular desaparecen después de salir de la página

En mi aplicación, tengo un campo de formulario que muestra una lista de opciones para elegir para el usuario. Cuando entro por primera vez en la página, todo está bien y puedo ver la lista. Pero si voy a otra página y luego vuelvo a la página que tiene el campo de formulario, las opciones ya no están allí. Y el servicio que se supone que muestra las opciones no se llama en la red. No entiendo por qué sucede esto. Aquí está mi código, ¿qué debo hacer para corregir este error?

HTML:

 <mat-form-field appearance="outline" fxFlex="100" fxFlex.gt-xs="30" class="w-100-p"> <mat-label>Receipt Group Type</mat-label> <mat-select formControlName="ReceiptGroupType" [required]="form.value['StockType'] != 4"> <mat-option *ngFor="let prm of receiptGroupTypeList" [value]="prm.Id"> {{prm.Name}} </mat-option> </mat-select> </mat-form-field>

TS:

 set Product(prm: IProduct) { if (prm != this._product && prm != null) { this._product = prm; } if (this._product && this._product.ProductId > 0) { this.filterProductCategories = this.productCategories.filter( (x) => x.ProductGroup.ProductGroupId == this._product.ProductGroup.ProductGroupId ); this.form = new FormGroup({ ReceiptGroupType: new FormControl( this._product.Receipt.ReceiptGroupType != null ? this._product.Receipt.ReceiptGroupType.Id:0 ), }); } else { this.form = new FormGroup({ ReceiptGroupType: new FormControl(0), }); } } get Product(): IProduct { return this._product; } constructor( private _adminService: AdminService, ) { let productId = this._activeRoute.snapshot.params["id"]; this._adminService.getReceiptGroupList().then((response:IBasicModel[])=>{ this.receiptGroupTypeList = response; }); }

Servicio TS:

 receiptGroupTypeList: IBasicModel[]; onReceiptGroupTypeListChanged: BehaviorSubject<any> = new BehaviorSubject( [] ); async getReceiptGroupList() { if (this.receiptGroupTypeList) { return undefined; } return await new Promise((resolve, reject) => { this._http .get("Parameter/GetReceiptGroupType") .subscribe((response: IBasicModel[]) => { this.receiptGroupTypeList = response; this.onReceiptGroupTypeListChanged.next( this.receiptGroupTypeList ); resolve(this.receiptGroupTypeList); }, reject); }); }
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!