I've been working on converting a JSON object into a TypeScript class with computed properties. My issue is that when I do the mapping, it correctly captures all the returned values but ignores the computed properties, even if they have default values.
My goal is for the ShowPanel property to default to true.
export class Maintenance {
Id?: number;
Name?: string;
// This computed property should be included in the object
ShowPanel: boolean = true;
}
@Component({
moduleId: module.id,
selector: 'app-home',
templateUrl: './home.component.html',
styleUrls: ['./home.component.scss']
})
export class HomeComponent {
ngOnInit(){
this.http.get('lookup/getstatusinformation')
.map(res => <Maintenance[]>res.json())
.subscribe(res => this.listMaintenance = res);
}
}