1. That single bracket is nothing, it is an empty object. Because you set it in the service myData为{},而且,你的getCtrl这个controller一开始就去获取了这个值,所以说在页面上会显示{};
2. The value when you click add按钮的时候,其实已经把input里面的值存入了myData中,只是你的getCtrl不会去获取而已,简单一点,你可以在getCtrl中也设置一个按钮来点击获取myData;
3. After your _getter函数中,你的这一句console.log..放在了return statement, no matter how you execute it, there will be no output.
I modified it slightly according to your code, you can take a look.
1. That single bracket is nothing, it is an empty object. Because you set it in the service
myData
为{}
,而且,你的getCtrl
这个controller一开始就去获取了这个值,所以说在页面上会显示{}
;2. The value when you click
add
按钮的时候,其实已经把input里面的值存入了myData
中,只是你的getCtrl
不会去获取而已,简单一点,你可以在getCtrl
中也设置一个按钮来点击获取myData
;3. After your
_getter
函数中,你的这一句console.log..
放在了return
statement, no matter how you execute it, there will be no output.I modified it slightly according to your code, you can take a look.