Skip to content

Commit 778f709

Browse files
committed
Add better comment.
1 parent a9c3bb2 commit 778f709

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/lib/input/input-container.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,13 @@ export class MdInputDirective {
176176
_onBlur() { this.focused = false; }
177177

178178
_onInput() {
179-
// This is a noop function and is used to let Angular recognize the changes
180-
// to the input element while typing. Listening to the `input` event is similar to NgControls.
179+
// This is a noop function and is used to let Angular know whenever the value changes.
180+
// Angular will run a new change detection each time the `input` event has been dispatched.
181+
// It's necessary that Angular recognizes the value change, because when floatingLabel
182+
// is set to false and Angular forms aren't used, the placeholder won't recognize the
183+
// value changes and will not disappear.
184+
// Listening to the input event wouldn't be necessary when the input is using the
185+
// FormsModule or ReactiveFormsModule, because Angular forms also listens to input events.
181186
}
182187

183188
/** Make sure the input is a supported type. */

0 commit comments

Comments
 (0)