I want to run a function based on a $scope value. In my controller, I have:
$scope.value = "";
$scope.selector = function(info) {
if ($scope.value === "") {
$scope.value = info;
} else {
$scope.value = "";
}
}
The function is triggered on ng-click of different images, e.g.:
<img ng-src="..." ng-click="selector(info)">
My problem is the if-operations dont seem to work on the $scope value. I have also tried:
$scope.$watch('value', function(val) {
if(val === "") {
$scope.value = info;
}
}
This works if it is outside a function, but not if I place it in the selector function. Better approaches always welcome. Thanks for any explanations.
infoinng-click="selector(info)"?