Skip to content
Advertisement

does angular have the “computed property” feature like in vue.js?

I learnt Vue.js first, and now have a project in Angular 4 so I just learnt Angular. I find everything is not that different from Vue except the “Computed Property”. In Vue, I can create a computed property that listens to changes of other properties and run calculations automatically.

For example(in Vue 2):

JavaScript

The name property will only recalculate when one of firstname or lastname change. How to handle this in Angular 2 or 4 ?

Advertisement

Answer

yes, you can.

In TS file:

JavaScript

and after that in html:

JavaScript

here is an example:

JavaScript
Advertisement