Hope someone can help me understand this behavior in Angular.
There is a simple input bound to a component variable using ngmodel two way-data binding. When the component initializes, the data is retrieved using the dataService which returns an employee object which works fine. But the thing is when i edit the value in the input box, the component variable employee's name changes but also the data in the service as well is changed which according to me is very weird. The data returned from the service should not be affected right? Find plunker below.
Kindly refer to this plunker https://plnkr.co/edit/wjuJLo?p=preview
getData() {
console.log(this.employee);
console.log(this.service.getEmp());
}
Thanks and Regards, Ashley