As a contrived example, let's say I have an angular controller that looks something like this:
function OverflowController($scope) {
// initialize the count variable
$scope.count = 0;
// pretend the overflow logic is complex and doesn't belong in a filter or view
var count = parseInt($scope.count);
if (count < 100) {
$scope.overflow = "normal";
}
else if (count < 200) {
$scope.overflow = "warning";
}
else {
$scope.overflow = "error";
}
};
and I have a view that looks like this:
<input ng-model="count">
<p>Count: {{count}}</p>
<p>Overflow? {{overflow}}</p>
How can I bind the overflow property of the scope to the count property in such a way that when the count is updated, the overflow automatically gets updated too?