我读到了关于 angularJS 的新语法controller as xxx
语法
InvoiceController as invoice告诉Angular实例化控制器并将其保存在当前范围的变量发票中.
可视化:

好的,所以$scope我的控制器中没有参数,控制器中的代码会更清晰.
但
我将不得不在视图中指定另一个别名
所以到现在为止我能做到:
<input type="number" ng-model="qty" />
....controller('InvoiceController', function($scope) {
// do something with $scope.qty <--notice
Run Code Online (Sandbox Code Playgroud)
现在我可以这样做:
<input type="number" ng-model="invoic.qty" /> <-- notice
....controller('InvoiceController', function() {
// do something with this.qty <--notice
Run Code Online (Sandbox Code Playgroud)
题
这样做的目标是什么?从一个地方删除并添加到另一个地方?
我很高兴看到我错过了什么.