I need to $ to watch a variable in an area, but it is never called. I found that this has something to do with ng-switch-when.
For example: http://jsfiddle.net/gGKGX/
angular.module("GuyModule",[]).controller("GuyController", function($scope) { $scope.something = "foo"; $scope.guy="This is guy"; $scope.$watch('guy', function(){ console.log("guy changed!"); } ); } ); <div ng-controller="GuyController" ng-app="GuyModule"> <div ng-switch="something"> <div ng-switch-when="foo"> <input ng-model="guy"/> </div> <div ng-switch-when="bar"> <button ng-click="something='bar'">Click me!</button> </div> </div> </div>
I expect "the guy has changed!" to print, but it is not, when I remove the "ng-switch-when", it works. How can I handle this?
By the way, the same thing happens with ui-if (from the angularui project).
source share