Call a function inside ngFor in angular2

后端 未结 9 1839
眼角桃花
眼角桃花 2020-12-06 05:08

Hello I am using Angular2 and wanted to fetch the server and get some values for each ID I get inside ngFor.

9条回答
  •  -上瘾入骨i
    2020-12-06 05:47

    Doesn't sound very good , however , the simplest way :

    here call a function that do something with 'item' and return something new

    Proper way :

    @Directive({
      selector: '[runDummyFunc]'
    })
    export class runDummyFunc {
    
      constructor() {}
      ngOnInit() {      
         this.runDummyFunc()
      } 
    
    }
    
    
    
    here call a function that do something with 'item' and return something new

    In your class :

          myFunction = ():void=>{
    
             console.log('whatever');
          }
    

提交回复
热议问题