How to call header component function to another component in angular 2?

后端 未结 5 922
别跟我提以往
别跟我提以往 2021-01-22 07:24

I want to call showmodel(displayType) from another compoent.How to call header component function to another component?

header.compoent.ts

5条回答
  •  醉梦人生
    2021-01-22 07:54

    As Angular 2 is based on components and component interaction, it is important to understand how data is passed from one component to another. Data is passed between components using property bindings. Take a look at the syntax below:

    
    

    value is a property of current component and user is a property for access another component

    you should use to @Input property

    import {Component, Input} from 'angular2/angular2'
    
    export Class exampleComponent{
      @Input() user: any ;
    }
    

提交回复
热议问题