Is using $scope.$watch bad manners?

Heard that using $scope.$watch is in bad taste in Angular.js. Is it really so? If so, then here's an example:

$scope.modelOne = false;
$scope.modelTwo = 'some string';


The first model is associated with the checkbox.
The second c input type="text"
If modelOne === true modelTwo fully translated to uppercase. If false, fully translated to lower case. How to do it without $watch, if possible generally such to make?
July 4th 19 at 23:48
1 answer
July 4th 19 at 23:50
Solution
In your case you should use ng-change(https://docs.angularjs.org/api/ng/directive/ngChange).
And $watch - Yes, a bad thing. Better to avoid it.
Okay, but I would like to get a definite answer about the $watch. Is it completely bad form or statement is exaggerated? - marge_Jaskolski commented on July 4th 19 at 23:53
: $scope is in principle not necessary in the Angular starting from version 1.5 - willow.Hand commented on July 4th 19 at 23:56
: $scope? or $scope.$watch? Can be a little more? - marge_Jaskolski commented on July 4th 19 at 23:59
: $scope as a whole. Look at the components, everything binding get into the controller. For the rest is bindToController: true. - willow.Hand commented on July 5th 19 at 00:02
: Thank you. - marge_Jaskolski commented on July 5th 19 at 00:05
: Could you point to some article, which shows the DOM without $scope.apply() and $scope.watch in the context of the 1.5 components (that is components, not directives)? Not so long ago had to do the integration with bootstrap datetimepicker is to make this thing work using the components that failed. Wound up only by the Directive apply and watch - madonna commented on July 5th 19 at 00:08
I have a similar problem: one backend does not know how to give data. As a result, must use jQuery.ajax. You have to apply the changes using $apply. But it special cases. - marge_Jaskolski commented on July 5th 19 at 00:11
components do not replace the guidelines for working with the DOM all the same they are used (see the first paragraph: https://docs.angularjs.org/guide/component ). And apply will have to be used in the case when there is a processing non-angular events. Watch almost ever need when it comes to input elements, because ng-model is able to very much. By the way I also this plugin hitched, use ng-model + parsers/formatters
: the $http service has transformRequest/transformResponse. - willow.Hand commented on July 5th 19 at 00:14

Find more questions by tags Angular