$scope.search is undefined. Please spot the error. [object Object ] appears on textbox

html tile

<form ng-submit="search()" name="searchcar"> 
<label class="item item-input">
<input type="text" placeholder="Search Chassis" ng-model="chassis" name="chassis" class="search_chassis_txt">
<input type="submit" value="" class="search_chassis" style="z-index: 2">
</label>
</form>

in controller.js

$scope.search = function(){
    if($scope.searchcar.$pristine){
        alert('Nothing to search.');
    }else{
        data = {
            'chassis': $scope.searchcar.chassis,
        };          
        $ionicLoading.show({template:'Searching....'});
    }
};

I have this error message that show: Error: $scope.searchcar is undefined. On the same line as $scope.searchcar.$pristine

Thanks.

After updating ng-model to searchcar.chassis, the value [object Object] appear on my textbox by default.

What is causes the text to appear?

If I remember correctly, the form itself is not created in the scope.

Pass the form as an argument to the search method:

<form ng-submit="search(searchcar)" name="searchcar"> 

Then change the method accordingly:

$scope.search = function(searchcar){
    if(searchcar.$pristine){
        alert('Nothing to search.');
    }else{
        data = {
            'chassis': searchcar.chassis,
        };          
        $ionicLoading.show({template:'Searching....'});
    }
};