Looks to me like the isSelected function is expecting an individual
"member" rather than memberList.

memberList.id === this.selectedId will simply return true or false
depending on if the property "id" of the object "memberList" is equal to
this.selectedId. There is no looping involved. I would imagine it should be
more like:

isSelected(member) {
  return member.id === this.selectedId;
}

assuming that the function is supposed to return a true/false value. There
are other methods to find the selected item in the array if you want to
return the member itself - for example something like:

selectedMember(memberList) {
  return memberList.find(i => i.id === this.selectedId);
}

Hope this helps.

On Mon, 30 Sep 2019 at 01:03, learningA <dawgho...@gmail.com> wrote:

> I'm working through a youtube tutorial and came across a code im not
> familiar with and need some clarification.
>
>     isSelected(memberList){
>     return memberList.id === this.selectedId;
>     }
>
> is the code:    return memberList === this.selectedId  like a foreach loop
> that iterating through the memberList array to match a selectedId?
>
> memberList is a list of test users.
>
> isSelected function which is bind to a class
>
>  <li  *ngFor="let user of memberList"  [class.selected]=
> "isSelected(memberList)">
>         <span class="badge" >{{user.id}}</span>
>         {{user.name}}
>       </li>
>
> the author of the tutorial demonstrating how to code the back button and
> how the list should be highlighted.
>
> --
> 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 angular+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/angular/8cf814e7-3020-42f8-a218-8ca432c93020%40googlegroups.com
> <https://groups.google.com/d/msgid/angular/8cf814e7-3020-42f8-a218-8ca432c93020%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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 angular+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/angular/CAO4zcUh09vyC2PkEgxuNJA-R2BSwy6UH7ZWeyCnCa9PqManA_A%40mail.gmail.com.

Reply via email to