Angular 2 *nfFor, problem iterate through object array

29 views
Skip to first unread message

Dawg

unread,
Dec 8, 2016, 6:42:59 PM12/8/16
to Angular
Hello,

I searched the internet and still not able to resolve my problem and could use some help. I also attached a image of console output.

this line of code works:
 {{ this.projectList[2]?.prj_name }} 

I like to iterate through the entire data set and tried different variation and its just not working and could use a little help with this problem:
<ul> 
     <li *ngFor="let test of this.projectList">
           {{test.prj_name}}
    </li>
</ul>


component.ts
this.projectList = this._bootStrapIncident.bootStrapIncidentMethod()  
  .subscribe(
data1 => {
this.projectList = data1;
console.log(this.projectList);
},


service.ts
 
return this._http
                .post(this.userUrl, options)
                .map((res: Response) =>  res.json())                
                .catch (this.handleError);  
   

Image of output


Sander Elias

unread,
Dec 8, 2016, 11:56:43 PM12/8/16
to Angular
Dawg,

You don't need the 'this.' part in your template. will not work.

Regards
Sander

Dawg

unread,
Dec 9, 2016, 12:05:07 PM12/9/16
to Angular
Hi Sander, Thanks for the reply...

couple of hours after the post I noticed the mistake and made correction..
spent 2 days trying to figure out why it wasn't working and it was the 'this'..
]
thanks again.

Vipul Singh

unread,
Dec 10, 2016, 1:30:42 PM12/10/16
to Angular
you cant bind this object in UI,becouse Dom doesnt know this keyword coming from html
Reply all
Reply to author
Forward
0 new messages