Angular 4 execute function from another component

前端 未结 2 2025
隐瞒了意图╮
隐瞒了意图╮ 2020-12-13 02:56

I\'m build a webapp using Angular4 and I\'m trying to create a button to call functions on other components.

I was reading other similar questions here, but they hav

2条回答
  •  一整个雨季
    2020-12-13 03:47

    I had a similiar situation, but didn´t want to make a service for this. I managed to pass it like callback. It would be something like this:

    header.component.ts

    @Component({
    selector: 'header',
    templateUrl: `
        
    `}) export class HeaderComponent { @Input() myFunction: Function; }

    Then just to call it passing the function and parameter

    // store.html
    

    And just declaring functionOnStore normally on store component

提交回复
热议问题