subscribe for value changes on ng-model
See original GitHub issueIf I have an input:
<form #todo="form">
<input type="text" ng-control="desc" [(ng-model)]="model.desc">
</form>
And I would like to subscribe to any changes to the model.desc
, how would one do it?
If I’d be using the form builder, I’d be doing the following:
that.form = fb.group({
desc: ['', Validators.required]
});
that.desc = that.form.controls.desc;
ObservableWrapper.subscribe(that.desc.valueChanges, function (value) {
// do something here
})
And of course the markup would be a bit different as well:
<form #todo="form" [ng-form-model]="form">
<input type="text" ng-control="desc">
</form>
But using the form builder and that.form.controls.desc
makes the TS compiler complain that the desc
property does not exist on a control.
Issue Analytics
- State:
- Created 8 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
How do I detect change to ngModel on a select tag (Angular 2)?
As we can see, if we select a different value from the dropdown, our ngModel changes, and the interpolated expression in the view...
Read more >ngModelChange and change events in Angular with examples
The value is updated by change event. As we used [ngModel] , on each input change ngModelChange will be called. And the UI...
Read more >Difference between (change) and (ngModelChange) in Angular
Using (ngModelChange) essentially is listening to the input event, and setting the model if a user types, pastes or changes the input's value....
Read more >NgModelChange & Change Event in Angular - TekTutorialsHub
NgModelChange is an Angular specific event, which we can use to listen for changes to the user input. It is the @Output property...
Read more >NgModel - Angular
It accepts a domain model as an optional Input . If you have a one-way binding to ngModel with [] syntax, changing the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Create a directive which has an
Observable
input. Attach this directive to your form and passtodo.form.valueChanges
to it.This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.