Problem
问题
You want to increment or decrement a property.
希望增加或者减少一个属性的值。
Solution
解决方案
Use the incrementProperty
or decrementProperty
methods of Ember.Object
.
使用Ember.Object
的incrementProperty
或decrementProperty
方法。
To increment:
增加属性值:
person.incrementProperty('age');
To decrement:
减少属性值:
person.decrementProperty('age');
Discussion
讨论
You can optionally specify a value to increment or decrement by:
可以选择指定需要增加或减少的值:
person.incrementProperty('age', 10);