Using Computed Property Names in Angular

Computed property names can come in handy when you have complicated properties

Image for post
Image for post
Photo by Clément H on Unsplash
export class ProfileEditorComponent { 
profileForm = new FormGroup({
firstName: new FormControl(‘’),
lastName: new FormControl(‘’),
});
}
export class ProfileEditorComponent { 
profileForm = new FormGroup({
‘firstName|Suffix’: new FormControl(‘’),
lastName: new FormControl(‘’),
});
}
export class ProfileEditorComponent { 
public endName= ‘computedLastName’;
profileForm = new FormGroup({
‘firstName|Suffix’: new FormControl(‘’),
[this.endName]: new FormControl(‘’),
});
}

Written by

I develop software by profession. My interests include: history, economics, politics & enterprise-architecture. I am a child of God.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store