javascript - $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 search.'); }else{ data = { 'chassis': $scope.searchcar.chassis, }; $ionicloading.show({template:'searching....'}); } };
i have error message show: error: $scope.searchcar undefined. on same line $scope.searchcar.$pristine
thanks.
after updating ng-model searchcar.chassis, value [object object] appear on textbox default.
what causes text appear?
if remember correctly, form not created in scope.
pass form argument search method:
<form ng-submit="search(searchcar)" name="searchcar">
then change method accordingly:
$scope.search = function(searchcar){ if(searchcar.$pristine){ alert('nothing search.'); }else{ data = { 'chassis': searchcar.chassis, }; $ionicloading.show({template:'searching....'}); } };
Comments
Post a Comment