Computed property

This is the most simple example. Take a look at this page's source and the javascript source, to see how it works.

There is a hidden easter egg, see if you can figure it out :-).




Computed property (with explicit watch for performance)

Adding a watch field will give you better performance because it will only execute the computed expression when one of the watched properties has changed. In our trivial example below it will give you very little performance benefit, but for more complicated expressions it can give a significant speedup.




Computed set property

You can also do computed setters.



Computed get & set properties

You can also combine getters and setters, make sure you add a watch array or you might get some unexpected behaviour.