function MyController($scope, Vm) {
const vm = this;
vm.myData = 'foo';
vm.myData; // 'foo'
const stopWatching = $scope.$watch('controllerAsName.myData', (newVal, oldVal) => {
doSomething(newVal, oldVal);
});
stopWatching();
// no way to remove all watchers from controllerAsName.myData
}
function MyController($scope, Vm) {
const vm = new Vm(this, 'controllerAsName');
vm('myData').val('foo')
vm('myData').val() // 'foo'
const watcher = vm('myData').watch($scope, (newVal, oldVal) => {
doSomething(newVal, oldVal);
});
vm('myData').stopWatching(watcher);
vm('myData').stopWatching(); // unregister ALL watchers.
}