2

Hello I am having problems accessing the value of my $scope.searchText. It keeps saying that it is undefined.

In my html page I have the following. (the {{searchText}} updates normally when I make changes.

<label>Filter: {{searchText}}
    <input class="form-control" ng-model="searchText"
           ng-change="testingChange()" placeholder="Search Projects" />
</label>

and in my controller it is initialized as:

$scope.searchText;
$scope.testingChange = function () {
    $scope.testArr = itContains(vm.projects, $scope.searchText);
    console.log($scope.searchText); //prints undefined.
    console.log($scope.testArr.length);
}

but as mentioned before, when I try to do console.log($scope.searchText) it shows undefined.

I am trying to return an answer based on the that variable. How do I access it?

Thanks in advance :)

georgeawg
  • 48,608
  • 13
  • 72
  • 95
Ronny Pacheco
  • 35
  • 1
  • 5

0 Answers0