简体   繁体   中英

loop on object angular 4 and lodash typescript error

I create simple loop on object in my pipe:

  transform(value: any, args?: any): any {
      let room;
      _.forEach(this.rooms,function (el,index) {
          console.log(el);
          if(el.id == value){
            room == el;
          }
      });
      return room;
  }

I can see on console that my object "el" has property id inside but i cant check it. I use lodash library to loop but i get error : " Property 'id' does not exist on type '{}'."

How can I avoid this do i have to create double loop to access one property ?

Try to use arrow function and see

_.forEach(this.rooms,(el: any) =>{
        console.log(el);
        if(el.id == value){
          room == el;
        }
    });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM