Angular doesn't recognize that when i put together model (string) and $scope to form $scope.model that it is indeed a defined scope variable. Is there anyway to not make model a string so $scope.model will actually refer to what I need it to refer to?
$scope.games = [];
$scope.maxplayers = 0;
$scope.minplayers = 0;
........
function setupWatcher(model){
$scope.$watch(model,function(){
console.log($scope.model); // prints out undefined
if(!$scope.model) return;
$http.get('/api/games?'+ model + '=' + $scope.model)
.success(function(data){
$scope.games = data;
})
.error(function(data){
console.log('Error' + data);
});
});
}
angular.forEach(['maxplayers',' minplayers'],setupWatcher);