My Server-side C# model
public class Instructor:Entity
{
public string Name { get; set; }
public string PhoneNo { get; set; }
}
Client-side TypeScript model
export class Instructor extends Entity {
public name:string;
public address:string;
public phoneNo :string;
}
Client-side service
getDataById(id: string):Observable<T> {
return this.repo.get(this.subUrl+'query',id).map( (res)=>{ return <T> res.json()})
}
Client-side controller
this.subscription= this.instructorService.getDataById(this.id).subscribe( (data:Instructor) =>{
console.log(data);
this.model.name=data.name;
console.log(this.model))};
Output result: Result displayed in browser
Is there a more efficient way to perform this mapping?
this.model.name=data['Name'];
I prefer using this approach for the mapping or any other better suggestions
this.model.name=data.name;
Your assistance is greatly appreciated