The function ng-click does not successfully uncheck ion-radio

In the process of developing my application using the ionic framework, I encountered a challenge where I needed to deselect an ion-radio button when clicking on an input tag. Despite attempting to achieve this functionality through this ionic play link, I was unable to do so successfully.

HTML

<ion-content class="padding">
    <label class="item item-input">
      <div class="input-label">
        <i class="ion ion-search"></i>
      </div>
      <input ng-click="uncheck($event)" type="text" ng-model="foodfilter" class="">
    </label>
    <ion-radio ng-model="filter.typefilter" ng-value="'A'">Choose A</ion-radio>
    <ion-radio ng-model="filter.typefilter" ng-value="'B'">Choose B</ion-radio>
    <ion-radio ng-model="filter.typefilter" ng-value="'C'">Choose C</ion-radio>
  </ion-content>

JS

$scope.uncheck = function (event) {
 if ($scope.filter.typefilter == event.target.value) $scope.filter.typefilter = false
}

Check out the ionic play link for more details

Answer №1

Make sure to implement ng-click on your input element for better functionality.

<input ng-click="uncheck($event)" type="text" ng-model="foodfilter" class="">

Remember that the value of filter.typeFilter is a string, so use value instead of ng-value.

<ion-radio ng-model="filter.typeFilter" value="A">Choose A</ion-radio>
<ion-radio ng-model="filter.typeFilter" value="B">Choose B</ion-radio>
<ion-radio ng-model="filter.typeFilter" value="C">Choose C</ion-radio>

To clear the radio boxes, simply set the value of ng-model to an empty string.

$scope.filter = {
    typeFilter: ""
}

$scope.uncheck = function (event) {
    $scope.filter.typeFilter = "";
}

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

Converting Javascript game information into PHP

Once the player loses, I need their score to be updated in the database using PHP. There is a separate JavaScript class that runs the game, utilizing setInterval to check the index.php function and update the database if the player loses. However, the issu ...

Using npm properties reader to access a key with multiple suite values from a properties file in Protractor

Recently, I had to find a way to store some data outside of the standard conf.js file. To tackle this requirement, I decided to use the properties-reader node module. However, I encountered some issues when trying to access certain key values. Below are e ...

Implement two different styles within an element's style properties

Welcome everyone, I have a question regarding adding marquee effects to a table row along with highlighting it. Is it possible to include moving text from left to right in the same active row? For example, let's say that the current time is 12:45 AM. ...

"Enhancing Error Handling in Express with Node.js Middleware for Parsing

I've been working on developing a middleware to manage errors, but I'm struggling to send the correct format to my frontend. Below, I'll outline my various attempts in the hopes of getting some guidance on this issue. Attempt 1 app.use(fun ...

Error: The function jquery_1.default is not recognized by webpack

I am encountering an issue with using external imports of jQuery in webpack. Despite trying different import syntaxes such as import $ from 'jquery', import * as $ from 'jquery, and const $ = require('jquery'), I continue to receiv ...

How can I set a background image to automatically adjust to the width of the window, be full height, allow for vertical scrolling, and

How can I set a full-screen background image that adjusts to the body width without horizontal scrolling, maintains height proportionate to width, and allows for vertical scrolling? Here is my current code: html, body { margin: 0px; padding: 0px; } bo ...

Discover the ins and outs of utilizing nested form associations within Phoenix

Currently diving into Phoenix 1.3 and eager to grasp ecto associations while leveraging Angularjs for the frontend. Two schemas at play: user.ex and profile.ex Both created using mix phx.gen.json user.ex schema "users" do field(:password_hash, :string) ...

The text of the keyword in AdGroupCriterionService remains unchanged

I've been utilizing the GoogleAds Node Module from https://www.npmjs.com/package/googleads-node-lib. I have successfully managed to modify the Tracking Template and the CpcBid microAmount, however, I am facing an issue with changing the keyword text. ...

Using Angular.js version 1.6.9, you can dynamically apply a class based on a condition by utilizing the

I am attempting to use ng-class in order to implement conditional styling within an ng-repeat. The condition is supposed to be based on the evaluation of a string within an object data. I am working to apply bold formatting to the 3rd item using this code ...

When using the <Routes> component, it will not render a component that acts as a container for multiple <Route> elements

Upon wrapping my component in <Routes>, I encountered this warning: Warning: [Categories] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment> In App.js: const App = () => ...

The 'fn' argument passed is not a valid function, instead it is a string

I am encountering an issue while trying to retrieve data from my server. The console doesn't provide any specific information about the error. My objective is to fetch JSON data from the server and use it to display the required information. I am util ...

Trouble implementing array filter in React component is a common issue

Hello everyone! I'm facing an issue with deleting an element from my useState array. I have the index of the element that I want to remove, and I've tried the following code snippet: const updatedArray = myArray.filter((item: any, index: number) ...

The Vue computed property is failing to retrieve the data it needs

I'm having trouble with the computed() property not retrieving data. Data was initialized in the created() property. Am I missing something here? Any guidance on how to resolve this issue would be greatly appreciated. const randomPlayers = { temp ...

Trouble reading property 'map' in a react-redux todo application

Greetings! I am currently in the process of developing a to-do list application, but I have encountered the following error: TypeError: Cannot read property 'map' of undefined Below is the code snippet where the error occurs: 4 | function T ...

Photo uploading in ASP.NET MVC - encountering null HttpPostedFileBase issue

QUESTION: I'm having an issue where the Photo1 value is null in the controller post method despite uploading it. Can someone help with this? This is my model class: class ProductVM{ public string Name { get; set;} public string Color {get; ...

Exploring the use of a customizable decorator in Typescript for improved typing

Currently, I am in the process of creating TypeScript typings for a JavaScript library. One specific requirement is to define an optional callable decorator: @model class User {} @model() class User {} @model('User') class User {} I attempted ...

Using jQuery to send LocalStorage data to an email address with the help of PHP

Currently, I am in the process of developing a basic eCommerce/checkout system. My goal is to utilize localStorage data and transfer it to PHP using jQuery or any other method that is convenient. However, when I attempted to send the email, I only received ...

Eliminate unneeded null and empty object data attributes within Vue.js

When sending object data to an API, I have multiple states but not all of them are required every time. Therefore, I would like to remove any properties from the object that are null or empty strings. How can I achieve this? export default { methods: { ...

I would appreciate your assistance with the hide button

Is there a way to hide a button after clicking on it? I would greatly appreciate your help! ...

"Extending Material-UI: Utilizing Multiple Snackbar Components

I've been struggling to display multiple warnings using Snackbar from the Material UI library in my React project. I haven't found any examples with React, only Vue. Can anyone help me with this? Here is the code that I have tried so far: https: ...