I have an EmployeeService that I inject into an EmployeeController. The EmployeeService contains an object.
I bind Service object into Controller Scope:
app.controller('EmployeeController', function($scope, EmployeeService) {
$scope.employee = EmployeeService.getEmployee();
}
HTML template displays the name of the Employee:
{{employee.name}}
If I manipulate the employee object in the EmployeeService ... i.e. EmployeeService.getEmployee().name = 'new name', the template displays the new name.
However, if I replace the employee object in the EmployeeService ... i.e. EmployeeService.setEmployee({name: 'new name'}) the template does not display the new name.
Why is replacing the Service object not reflected in the template?
I have the following Plunk that demonstrates this: http://plnkr.co/edit/k7oKd1VgsBvMGvVdP5kM?p=preview
In my Plunk, Employee Controller/Service works and Manager Controller/Service does not.
If anyone could help me understand what is going on I would really appreciate it.