Unable to clear input field after submitting form in AngularJS with Ionic framework

Something strange is happening. Whenever I try to clear the model in the controller, the input field that is bound to the model using ng-model does not get cleared when the form is submitted.

Controller

angular.module('starter.controllers', [])
.controller('DashCtrl', ["$scope", function($scope) {
    $scope.clearInput = function() {
      console.log("I get there...");
      //This is where the problem lies! It's not clearing as expected!
      $scope.message = "";
    };
}]);

Template

<ion-view title="Dashboard">
    <ion-content class="padding">
        <form name="myform" ng-submit="clearInput()">
            <label class="item item-input">
                <input type="text" ng-model="message"/>
            </label>
            <button type="submit" class="button button-positive" >
                Submit
            </button>
        </form>
    </ion-content>
</ion-view>

The console shows "I get there" so the function is being triggered. What am I missing here?

Answer №1

clearInput() and ng-model pertain to separate scopes once the input value has been altered. For a more detailed explanation, take a look at this insightful response on Stack Overflow.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Trouble with concealing the headers of a table in AngularJs

I am currently working on developing an angular application that displays football scores. Users can select the option for 2015 matches and only view information for games played in that year. However, I'm facing an issue where even when the 2015 chec ...

Ionic: Error - Unable to access the 'ready' property of an undefined object

I keep encountering this error message: TypeError: Cannot read property 'ready' of undefined Here is the snippet of my code: angular.module('app', ['ionic', 'app.controllers', 'app.routes', 'app.dir ...

Organizing content by title or link using jQuery

I am attempting to organize a list based on the title of a link so that it is displayed in an A-Z format. Unfortunately, I am unable to modify the HTML structure easily for better styling as I am restricted to using tr>tr>tr>. I am struggling to f ...

After a period of running NodeJS and AngularJS together, I am encountering the net::ERR_CONNECTION_RESET error

My setup includes Express with NodeJS and AngularJS on the front-end. However, after performing a series of actions such as adding data, updating records, and showing a list, I encounter the error net::ERR_CONNECTION_RESET. Interestingly, this error only o ...

How can I determine the size of the custom options dropdown in Magento?

I'm facing a challenging issue that I can't seem to crack. It might be because I'm still learning the ropes and struggling with technical jargon. Please bear with me as I try to explain my problem. Here is a summary of what I'm trying ...

How can I assign integer values to specific child elements after splitting them?

Below is the HTML code that needs modification: <div class="alm-filter alm-filter--meta" id="alm-filter-1" data-key="meta" data-fieldtype="checkbox" data-meta-key="Cate" data-meta-compare="IN" data-meta-type="CHAR"> <ul> <li class=" ...

Is it possible to simultaneously use the same plugin with various configurations and unique names in Vue?

I'm attempting to utilize the Vue Currency Input plugin, specifically with two different configurations simultaneously: import Vue from 'vue' import VueCurrencyInput from 'vue-currency-input' const options = { globalOptions: { ...

What techniques work well for managing permission tiers within the MEAN stack environment?

Following the insights from the book "MEAN Machine", I successfully implemented a basic token-based authentication system that restricts access to certain model data to authenticated users. Now, I am eager to enhance this system by introducing three disti ...

Handlebars does not support loading data into variables using Express

My NodeJS/Express application utilizes Handlebars for templates, and everything works smoothly except when attempting to display data retrieved from an Express API. The data is successfully fetched and can be viewed in the Chrome debugger. In the problem ...

Anticipating the completion of a process.nextTick cycle

Problem Statement I am currently working on a Node.js application that involves complex calculations and utilizes recursive algorithms. The code snippet below gives a brief overview of how the calculations are performed: // routes.js - express.js routes ...

Merge topics together in RxJS like zip

Is it possible to create an observable that combines two subjects in a unique way, different from the zip function? The goal is to combine two subjects so that when both have emitted values, the latest of their values is emitted. Then, after both emit at ...

MUI Modal overlay for stylish Ionic select dialogues

In my react application, I am utilizing the MUI library, but there are instances where I still need to incorporate Ionic framework in the code. ISSUE: When opening MUI modal windows that contain Ionic selects, the select modals end up being covered by the ...

What is the syntax for implementing a nested for loop in JavaScript within this particular scenario?

var entries = [ { "item": "something", "steps": [{ "node": {"name": "test0"}, "status": {"name": "test"}, "time": {"name": "test"} },{ "node": {"name": "test1"}, ...

vue utilize filtering to search through a nested array of objects within a parent array of objects

After making an API call, I receive JSON-formatted data with a specific structure like this: data = [ { name: 'John', school:[ { school_name: 'Harvard', date_attended: '2017-05-23' }, { schoo ...

Connecting AngularJS with select options

I am currently developing a checkout feature that calculates shipping prices based on the selected country. If the user picks United States, it should display US. For any other country selection, it should show Not US While the shipping function correctly ...

Check if ng-bind-html has completed loading in AngularJS before applying syntax highlighting to the code

I have integrated ng-bind-html to display data retrieved from the database. <p ng-bind-html="myHTML"></p> app.controller('customersCtrl', function($scope, $http, $stateParams) { console.log($stateParams.id); $http.get("a ...

No Angularjs redirection without the "onload" event

In my search for a solution, I came across this answer but it did not quite fit my needs: Pass onload event through redirect The issue I'm facing is that I want the AngularJS section of my application to reload something when the user is redirected ...

Transform a date string into a date entity

Collecting the user's input for the date and saving it as a string variable. The format of the value is Fri Aug 27 2021 00:00:00 GMT+0530 (India Standard Time) My goal is to convert this string back into a new Date() object in order to make additiona ...

Experience the captivating AUTOPLAY feature of the mesmerizing FULLSCREEN SLIT SL

I am currently utilizing a slider that is functioning well, however I am encountering an issue with autoplay. Whenever I click on the navigation arrow or Nav dot at the bottom of the slider, the autoplay feature stops working. For more information, please ...

The ng-route feature seems to be malfunctioning and I am unable to identify the error, as no information is being displayed in the console

Here is the code in my boot.php file where I have set up the links <ul class="nav nav-pills nav-stacked"> <li role="presentation"><a href="#/valley">Valley</a></li> <li role="presentation"><a href="#/beach"> ...