ionic-team / ionic-framework

A powerful cross-platform UI toolkit for building native-quality iOS, Android, and Progressive Web Apps with HTML, CSS, and JavaScript.
https://ionicframework.com
MIT License
50.47k stars 13.53k forks source link

feat: Expose ion-input/ion-searchbar value as a signal in Angular #29370

Closed JulienLecoq closed 3 weeks ago

JulienLecoq commented 3 weeks ago

Prerequisites

Describe the Feature Request

I would like the value property of ion-input, ion-searchbar and similar components to be exposed as signals instead of raw values. This would allow to enhance reactivity and performance in Ionic apps built with Angular by working smoothly with the OnPush change detection and the future Signal based change detection.

I myself created wrapper around Ionic components to have such fields exposed as signals.

Describe the Use Case

Allows to easily listen to changes, and create computed values from inputs. Allows to easily use OnPush change detection, for example this, becomes possible and is reactive if used inside templates:

isEmpty() {
    this.myInput().value() === "" || this.myInput().value() === undefined || this.myInput().value() === null
}

Describe Preferred Solution

Just expose a field which would hold the current input value as a signal.

Describe Alternatives

No response

Related Code

No response

Additional Information

No response

liamdebeasi commented 3 weeks ago

Thanks for the report. I am going to close this since this behavior is already achievable in Ionic Framework. Developers should use the model signal to have reactive signals with Ionic component values:

<ion-searchbar [(ngModel)]="searchbarValue"></ion-searchbar>

import { model } from '@angular/core';

...

searchbarValue = model('123');