In mdChipsCtrl
gibt es eine boolesche Variable, die dafür verantwortlich ist, den Fokus auf den Eintrag shouldFocusLastChip
zurückzusetzen.
ich überschrieben die Funktion, indem Sie den Wert dieser Variablen mit der folgenden Richtlinie zu ändern:
angular.module('myApp').directive('mdChips', function() {
return {
restrict: 'E',
require: 'mdChips', // Extends the original mdChips directive
link: function (scope, element, attributes, mdChipsCtrl) {
mdChipsCtrl.appendChip = function (newChip) {
// Set to FALSE
this.shouldFocusLastChip = false;
if (this.useTransformChip && this.transformChip) {
var transformedChip = this.transformChip({'$chip': newChip});
// Check to make sure the chip is defined before assigning it, otherwise, we'll just assume
// they want the string version.
if (angular.isDefined(transformedChip)) {
newChip = transformedChip;
}
}
// If items contains an identical object to newChip, do not append
if (angular.isObject(newChip)){
var identical = this.items.some(function(item){
return angular.equals(newChip, item);
});
if (identical) return;
}
// Check for a null (but not undefined), or existing chip and cancel appending
if (newChip === null || this.items.indexOf(newChip) + 1) return;
// Append the new chip onto our list
var length = this.items.push(newChip);
var index = length - 1;
// Update model validation
this.ngModelCtrl.$setDirty();
this.validateModel();
// If they provide the md-on-add attribute, notify them of the chip addition
if (this.useOnAdd && this.onAdd) {
this.onAdd({ '$chip': newChip, '$index': index });
}
};
}
};
ich nicht in der Lage bin, dies wieder herzustellen. Welchen Browser benutzen Sie? –
Live-Beispiel von [Angular Material 1.1.4] (https://fiddle.jshell.net/nxvp1mdu/3/) und [Angular Material 1.1.1] (https://fiddle.jshell.net/c1osj4p7/2/) –