This repository has been archived by the owner on Sep 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(chips): add support for custom separator keys
Add the ability for chips to be created on keydown of any key code in the `md-separator-keys` attribute. Custom key codes are supported in addition to common ones defined in `$mdConstant.KEY_CODE`. Closes #5279. Closes #5281.
- Loading branch information
1 parent
b52f254
commit 5f5ae45
Showing
6 changed files
with
106 additions
and
16 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<div ng-controller="CustomSeparatorCtrl as ctrl" layout="column" ng-cloak> | ||
<md-content class="md-padding" layout="column"> | ||
|
||
<h2 class="md-title">Use <code>md-separator-keys</code> to customize the key codes which trigger chip creation.</h2> | ||
<p>Common key codes found in <code>$mdConstant.KEY_CODE</code> can be used alongside your own.</p> | ||
<md-chips | ||
ng-model="ctrl.tags" | ||
md-separator-keys="ctrl.keys" | ||
placeholder="Enter a tag" | ||
secondary-placeholder="Comma separated tags"></md-chips> | ||
<br/> | ||
|
||
<h2 class="md-title">Add custom separator key codes such as semicolon for e-mails.</h2> | ||
<md-chips | ||
ng-model="ctrl.contacts" | ||
md-separator-keys="ctrl.customKeys"></md-chips> | ||
|
||
</md-content> | ||
</div> |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
(function () { | ||
'use strict'; | ||
angular | ||
.module('chipsCustomSeparatorDemo', ['ngMaterial']) | ||
.controller('CustomSeparatorCtrl', DemoCtrl); | ||
|
||
function DemoCtrl ($mdConstant) { | ||
// Use common key codes found in $mdConstant.KEY_CODE... | ||
this.keys = [$mdConstant.KEY_CODE.ENTER, $mdConstant.KEY_CODE.COMMA]; | ||
this.tags = []; | ||
|
||
// Any key code can be used to create a custom separator | ||
var semicolon = 186; | ||
this.customKeys = [$mdConstant.KEY_CODE.ENTER, $mdConstant.KEY_CODE.COMMA, semicolon]; | ||
this.contacts = ['test@example.com']; | ||
} | ||
})(); |
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