HI

Im trying to output the address details of the user from backend and to 
display on html page in an ionic angular project

Here the address details has three fields

Address line1 (mandatory), Address line2 and Address line 3 (non mandatory)

when i try to out these address details in line separated by commas. iam 
getting extra commas when addressline 2 and 3 are not filled.

i want the commas to shown only if the next two fields are filled else dont 
want to show

Below is my code.

TS File: 

  getAddress() {

    this.apiService.getAddress().then(

      res => {

        this.primaryAddrArray = [this.primaryAddress.addressLine1, 
this.primaryAddress.addressLine2, this.primaryAddress.addressLine3];

     }

}

HTML page: 

<h1> Address: </h1>

<p *ngFor="let addr of primaryAddrArray; let i=index">{{addr}}, </p> 

because of the comma used after {{addr}} iam getting commas after each 
address line.

also tried like this

<h1> Address: </h1>

<p *ngFor="let addr of primaryAddrArray; let i=index">{{addr} 
{{primaryAddrArray = null ?  ' ' : ','}} </p>
getting output as  

*Address:*

*9th Avenue block,,,*

I dont want extra commas if the remaining two address fields are not 
filled. please assist me on this. 

Thank you


 

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/angular/d382b177-7b47-4a6f-8984-1ccb8394c8abn%40googlegroups.com.

Reply via email to