I'm starting a project with AngularJs (v 1). And that was nice until I started to wonder about the quality of my project. Because now I try to avoid abusing the $scope, $scope.$apply, $scope.broadcast and other nice things like that.
So now, all of my _controller_s are using var vm = this; instead of $scope and my directives are using callbacks instead of $scope.$apply. The problem I have is that the changes are not updated.
While the usage of $scope.$apply from a model attribute inside a directive was automatically updating the views it is not the case with a callback to a controller that update the model attribute. Then a workaround is to use _event_s but since $scope.$broadcast and his friends is not recommended, I have to create my own observers.
But at the end, I have the feeling to loosing the cool features of AngularJs. And started to wonder how are professionnals doing.
- How do you ensure that changes made to a model are updated to a view ?
- How you ensure that changes made to a model from a view are updated to another (master-details) ?
Thanks a lot for your advices.