-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
update(): add event object for slide-toggle and checkbox. #554
Merged
jelbourn
merged 3 commits into
angular:master
from
devversion:update/checkbox-emit-value
May 31, 2016
Merged
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,12 @@ export const MD_SLIDE_TOGGLE_VALUE_ACCESSOR: any = { | |
multi: true | ||
}; | ||
|
||
// A simple change event emitted by the MdSlideToggle component. | ||
export class MdSlideToggleChange { | ||
source: MdSlideToggle; | ||
value: boolean; | ||
} | ||
|
||
// Increasing integer for generating unique ids for slide-toggle components. | ||
let nextId = 0; | ||
|
||
|
@@ -59,8 +65,10 @@ export class MdSlideToggle implements ControlValueAccessor { | |
@Input() ariaLabel: string = null; | ||
@Input() ariaLabelledby: string = null; | ||
|
||
@Output('change') private _change: EventEmitter<boolean> = new EventEmitter<boolean>(); | ||
change: Observable<boolean> = this._change.asObservable(); | ||
@Output('change') | ||
private _change: EventEmitter<MdSlideToggleChange> = new EventEmitter<MdSlideToggleChange>(); | ||
|
||
change: Observable<MdSlideToggleChange> = this._change.asObservable(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This shouldn't be a big deal - Updated. |
||
|
||
// Returns the unique id for the visual hidden input. | ||
getInputId = () => `${this.id || this._uniqueId}-input`; | ||
|
@@ -144,7 +152,7 @@ export class MdSlideToggle implements ControlValueAccessor { | |
if (this.checked !== !!value) { | ||
this._checked = value; | ||
this.onChange(this._checked); | ||
this._change.emit(this._checked); | ||
this._emitChangeEvent(); | ||
} | ||
} | ||
|
||
|
@@ -173,6 +181,13 @@ export class MdSlideToggle implements ControlValueAccessor { | |
} | ||
} | ||
|
||
private _emitChangeEvent() { | ||
let event = new MdSlideToggleChange(); | ||
event.source = this; | ||
event.value = this.checked; | ||
this._change.emit(event); | ||
} | ||
|
||
} | ||
|
||
export const MD_SLIDE_TOGGLE_DIRECTIVES = [MdSlideToggle]; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think for checkbox and slide-toggle we'd want the property to be
checked
instead ofvalue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done