angular input properties

import { Component, OnInit, Input } from '@angular/core';

@Component({
  selector: 'app-order',
  templateUrl: './order.component.html',
  styleUrls: ['./order.component.css']
})
export class OrderComponent implements OnInit {

  @Input()
  orderName: string;

  @Input()
  count: number;

  constructor() { }

  by OnInit () {
    setInterval(() => {
      this.orderName = 'bbb';
    }, 3000);
  }

}
<p>
  Buy {{count}} lots of {{orderName}} products
</p>
import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {

  orderName: string;


  count: number;
}
<input [(ngModel)]='count'>
<input [(ngModel)]='orderName'>
<app-order [count]='count' [orderName]='orderName'></app-order>

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324855210&siteId=291194637