Angular $scope.form Value undefined on Submit in Ionic Framework

By Hardik Savani October 20, 2023 Category : jQuery Angular Ionic Framework

When i was working first time in ionic framework with search module. i fetch one issue i can't get ng-model value in angular js controller on submit form. i was try like $scope.form because if you work on angular JS before then you can get all post data using $scope.form directly, But i try with bellow form and try to get that way but i always find undefined value on form, But at last i found how to solve this issue. you can see bellow example and find your solution.

Form

<form method="POST" name="searchForm" ng-submit="search()">

<div class="item item-input-inset">

<label class="item item-input">

<input ng-model="form.keyword" type="text" required>

</label>

<button class="button-calm" type="submit">

<i class="icon ion-search"></i>

</button>

</div>

</form>

Controller

.controller('SearchCtrl', function($scope,$http) {

$scope.posts = [];

$scope.search=function(){

var form = this.form;

console.log(form);

$http.post(url+'/api/get_search_post',form).success(function(items) {

$scope.posts = $scope.posts.concat(items.data);

});

};

});

Tags :
Shares