this is a fundamental question about MVC (in particular using AngularJS) and I've found similar questions here, but not the exact same problem:
Could the view call a function of the model, or should it only call functions of the controller?
Here's the example:
In my Model there's a function to delete items of a collection, like this:
function deleteItems(searchExpression) { ... }
Now my Controller has an instance of my model including that function, like this:
$scope.data = queryModelFactory.getModel();
I now want to call that funciton when the user clicks a certain element in the HTML page:
<div ng-click="data.deleteItems('blabla')">Remove Items</div>
Is that legit? Or would it be better to implement a function in the controller that is passing through the delete request to my model like I'd do in a classical layer architecture? Like this:
function deleteItems(searchExpression) {
$scope.data.deleteItems(searchExpression);
}