Skip to content

Commit 89c4310

Browse files
committed
Add better comment.
1 parent 34037c7 commit 89c4310

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
@@ -158,8 +158,13 @@ export class MdInputDirective {
158158
_onBlur() { this.focused = false; }
159159

160160
_onInput() {
161-
// This is a noop function and is used to let Angular recognize the changes
162-
// to the input element while typing. Listening to the `input` event is similar to NgControls.
161+
// This is a noop function and is used to let Angular know whenever the value changes.
162+
// Angular will run a new change detection each time the `input` event has been dispatched.
163+
// It's necessary that Angular recognizes the value change, because when floatingLabel
164+
// is set to false and Angular forms aren't used, the placeholder won't recognize the
165+
// value changes and will not disappear.
166+
// Listening to the input event wouldn't be necessary when the input is using the
167+
// FormsModule or ReactiveFormsModule, because Angular forms also listens to input events.
163168
}
164169

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

0 commit comments

Comments
 (0)