javascript - Angular 2 : property binding and side effects

标签 javascript angularjs angular angular2-template angular2-directives

所以我一直在阅读官方文档《Angular2的模板语法》angular.io在属性绑定(bind)“避免副作用”的子标题中,我看到这些我不理解的行

We can’t assign a value to anything in a property binding expression nor use the increment and decrement operators. our expression might invoke a property or method that has side effects. Angular has no way of knowing that or stopping us.

最佳答案

不支持在属性绑定(bind)表达式中将 'yyy' 分配给 xxx

<div [someProp]="xxx = 'yyy'"> <!-- doesn't work -->

不支持使用递增和递减运算符

<div [someProp]="xxx++"> <!-- doesn't work -->

关于javascript - Angular 2 : property binding and side effects,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38670736/

相关文章:

javascript - 使用 ng-bind 时更新指令中的数据

angularjs - 使用angularjs在ng-repeat中显示数组的数量

Angular2 - 调用 constructor() 与 new 关键字来创建对象?

javascript - react useEffect 和异步获取

javascript - 如何创建两个相同的数组并仅更改其中一个的值?

javascript - 搜索价格文本,执行功能,并替换为输出

angularjs - 即使正在编辑输入,表单也未设置为 $dirty

JavaScript。在前端使用 async 和 wait 安全吗?

javascript - 在我的应用程序中添加 appRoutes 后未捕获的 TypeError : Cannot read property 'id' of undefined at registerNgModuleType (core. js)

javascript - 加载动态数组中的最终图像后如何调用函数?