Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

248
Visualizações
how to collect data from template and prepare post request from exact item

I am getting user data from backend and i need to change exact user information and send it to the backend, i make UI part with select and etc, so the question is:

How to collect changed data for an exact item from the template without form and prepare a post request body?

sorry if I explained badly. check the code below!

export class UsersComponent implements OnInit {

  public isLoading: boolean = true;

  public firstLoading: boolean = true;

  public langChangeObs: Observable<number | null> = this.storeService.selectedLangId;

  public users: IUserManagement[] = [];

  public roles: IRolesList[] = [];

  // @ts-ignore
  private langId: number;

  private ngUnsubscribe: Subject<void> = new Subject<void>();

  constructor(private storeService: StoreService,
              private http: HttpClientService) { }

  ngOnInit(): void {
    this.subscribeToChangeLang();
    this.getData();
  }

  private subscribeToChangeLang() {
    this.langChangeObs.pipe(
      takeUntil(this.ngUnsubscribe)
    ).subscribe(langId => {
      this.langId = langId as number;
    });
  }

  private getData() {
    this.http.getUsers(this.langId).subscribe((data: any) => {
      console.log(data);
      this.users = data.users.data;
      this.roles = data.roles.data;
    });
  }

  public sentUserChange() {
  }

  ngOnDestroy(): void {
    this.ngUnsubscribe.next();
    this.ngUnsubscribe.complete();
  }

}
<nb-card size="large">
  <nb-list>
    <nb-list-item class="users" *ngFor="let user of users">
      <div>
      <nb-user [name]="user.name">
      </nb-user>
      </div>
      <div>
        <span class="label">Email:</span>
        <input nbInput type="text" [(ngModel)]="user.email">
      </div>
      <div>
        <span class="label">Role:</span>
      <nb-select class="role-select" size="small" placeholder="{{user.role.role}}" [(selected)]="user.role.role">
        <nb-option *ngFor="let role of roles" [value]="role.id">{{role.human_readable}}</nb-option>
      </nb-select>
      </div>
      <div>
        <button click="sentUserChange()" nbButton>Save</button>
      </div>
    </nb-list-item>
  </nb-list>
</nb-card>

UI image

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda