Angular2: what expressions can we interpolate in template

时间秒杀一切 提交于 2019-12-01 19:41:47

Expressions in Angular2 are very similar to expressions in Angular in terms of the scope of what they allow.

JavaScript expressions that promote side effects are prohibited including

  • Assignment (= +=, -=)
  • Using the new keyword
  • Chaining expressions using a semicolon or comma
  • Increment (++) and decrement operators

Furthermore, there is no support for bitwise operators like | or &

Generally, it's a good idea to put complex JavaScript logic inside a controller or component, instead of inside a view. This is because of the Separation of Concerns design principle and making code more modular and readable.

https://angular.io/docs/ts/latest/guide/template-syntax.html#!#template-expressions

You can use the Angular 2 default pipes for evaluating the expression inside an interpolation. Please refer the below link https://www.npmjs.com/package/angular2-pipes#sum

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!