JavaScript generic controls and Angular 2+ best practice