Answer the question
In order to leave comments, you need to log in
When the data in the service changes, it does not change in the view.?
Previously, the data was stored in the controller and, if they were not updated by themselves, wrote
$scope.$apply ( function (results) {
$scope.resers = results;
});
Now I moved the code to the service, but the updated data is not visible in the view.
The service does not want to "inject" $scope - it swears.
What should I do to see the changed data?
Answer the question
In order to leave comments, you need to log in
The service must return a method, for example, getAll, which is called in the controller. It in turn gives an array of elements.
Inject the Service, then in the controller write
$scope.items = Service.getAll();
In order for us to help you, you could take the trouble to give an example here of how you get data in a controller from a service and how you store/modify data in a service.
Otherwise, you can guess for a very long time
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question