From here
In general, a Controller shouldn't try to do too much. It should contain only the business logic needed for a single view.
I can't understand why it's controller. It must be model. Please,explain.
EDIT:
This is the example from official developer guider:
angular.module('invoice1', [])
.controller('InvoiceController', function() {
this.qty = 1;
this.cost = 2;
this.inCurr = 'EUR';
this.currencies = ['USD', 'EUR', 'CNY'];
});
<div ng-app="invoice1" ng-controller="InvoiceController as invoice">
<b>Invoice:</b>
<div>
Quantity: <input type="number" min="0" ng-model="invoice.qty" required >
</div>
<div>
Costs: <input type="number" min="0" ng-model="invoice.cost" required >
<select ng-model="invoice.inCurr">
<option ng-repeat="c in invoice.currencies">{{c}}</option>
</select>
</div>
What I don't understand is that controller = model here. Am I not right?
You can see there models are 'inside' the controller's scope.
qty,cost,inCurrandcurrenciesas individual models, instead of all as one. There is even an argument to usethis.viewModelinside the controller, which would make this a lot clearer.