I am trying to change a variable by using a filter. Which looks like this.
<select ng-init="inputStatus='ALL'" ng-model="inputStatus">
<option value="ALL">ALL</option>
<option value="NEW">NEW</option>
<option value="RENEW">RENEW</option>
<option value="FINISHED">FINISHED</option>
<option value="FAILED">FAILED</option>
</select>
As you can see each time I select a new option the variable will change.
This is my $watch function.
var testValue = '';
$scope.$watch('inputStatus', function(val) {
if (val) {
testValue = val;
}
}, true);
console.log(testValue);
I need to use testValue here in order to filter through the data.
$http.get("/api/v1/websites/?limit=" + $scope.main.limit + "&offset=" + $scope.main.offset + "&status=" + testValue)
then(function successCallback(result) {
$scope.websites = result.data.results;
});
How can I do that?
$watchcall and the$httpcall in different controllers/scopes?<select>can haveng-change="doSomething(inputStatus)". It also depends on wheretestValueis located and if$httpcan reach it (otherwise consider using Service/Factory)