ItSolutionStuff.com

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

By Hardik Savani • October 20, 2023
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: Angular
Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

How to Install Tailwind CSS in Angular?

Read Now →

Angular Get Current Used Port Number Example

Read Now →

Angular Material Select Option Group Example

Read Now →

Angular Material Carousel Slider Example

Read Now →

Angular Pipe for Phone Number Example

Read Now →

Angular Material Input Autocomplete Example

Read Now →

Angular Get Active Route URL Example

Read Now →

Angular Get Parameters from URL Route Example

Read Now →

How to Get Current URL in Angular?

Read Now →

Angular Change Date Format in Component Example

Read Now →

Reactive Form with Validation in Angular 8

Read Now →