Pass variable to custom component

后端 未结 2 1905
感情败类
感情败类 2020-12-08 18:36

I have my custom component:

@Component({
    selector: \'my-custom-component\',
    templateUrl: \'./my-custom-component.html\',
    styleUrls: [\'./my-custo         


        
2条回答
  •  情书的邮戳
    2020-12-08 19:07

    You can add an @Input() decorator to a property on your component.

    export class MyCustomComponent {
        constructor() {
            console.log('myCustomComponent');
        }
    
        @Input() title: string;
    }
    
    
    
    

    or binding title from a variable 'theTitle'

    
    

    See the @Input()decorator documentation.

提交回复
热议问题