Hamdy
Hamdy

Reputation: 440

toUpperCase inside ngOnInit

I want to change the values when I receive the data from the provider.

  ngOnInit() {
    this.recapServiceProvider.getRecapPremevementt().subscribe(data => {
      this.recap = data;
      this.recap.forEach(element => {
        this.recap.type=element.type.toUpperCase();       
        console.log(this.recap.type);
      });
      console.log(this.recap);
    });
  }

When I try to console the "console.log(this.recap.type)", it shows me that the type is in upper case but on the dom and on the second console.log(this.recap) nothing changes.

How I can resolve that problem ?

Upvotes: 0

Views: 46

Answers (2)

Fateh Mohamed
Fateh Mohamed

Reputation: 21397

You can use a built in Pipe for that

{{recap.type| uppercase}}

Upvotes: 1

pioro90
pioro90

Reputation: 694

I think this is what you looking for.

this.recapServiceProvider.getRecapPremevementt()
        .map(data => data.map(el => el.type.toUpperCase()))
        .subscribe(data => {
            console.log(data);
    });

Upvotes: 0

Related Questions