我有两个控制器和一个服务。有人可以解释一下为什么名字不会更新/更改时引用是“旧的”吗?
我认为这是控制器之间通信的方式......?
<!-- language: lang-js -->
// Controller 1
function controllerOne (..., myService) {
$scope.firstname = myService.customer.firstname;
}
// Controller 2
function controllerTwo (..., myService) {
$scope.firstnameNew = myService.customer.firstname;
}
// Service
application.factory('myService', ...)
function(...) {
return {
customer: {
"firstname": "",
"lastname": "",
"pers": "",
"street": "",
"zip": "",
"city": "",
"selectedCountry": "",
"comment": ""
},
...
}