Angular HTML binding

后端 未结 21 2744
暖寄归人
暖寄归人 2020-11-21 04:00

I am writing an Angular application and I have an HTML response I want to display.

How do I do that? If I simply use the binding syntax {{myVal}} it en

21条回答
  •  忘掉有多难
    2020-11-21 04:45

    In Angular 2 you can do 3 types of bindings:

    • [property]="expression" -> Any html property can link to an
      expression. In this case, if expression changes property will update, but this doesn't work the other way.
    • (event)="expression" -> When event activates execute expression.
    • [(ngModel)]="property" -> Binds the property from js (or ts) to html. Any update on this property will be noticeable everywhere.

    An expression can be a value, an attribute or a method. For example: '4', 'controller.var', 'getValue()'

    Example here

提交回复
热议问题