1. Something useful staff

1.1. *ngIf, [hidden]

  • *ngIf removes DOM.
  • [hidden] = "condition" hides DOM.

1.2. Class

  • [class.green] = "condition"
  • [ngClass] = "{ green: condition, alert: condition }"
  • [ngClass] = "aFun()"
aFun () {
  return { green: condition, alert: condition }
  // or
  return [ 'class1', 'class2' ]
  // or
  return 'class1 class2'
}

1.3. Style

  • [style.color] = "a === a ? '#fff': '#000'"
  • [ngStyle] = "{ color: a === a ? '#fff': '#000', background: b === b ? 'yellow': 'green' }"
Copyright © Guanghui Wang all right reserved,powered by GitbookFile Modified: 2019-08-25 13:56:34

results matching ""

    No results matching ""