我使用下面的代碼來獲取「自動標籤」與AngularJS工作(自動選項卡上的用戶在「標題」文本框的最大長度爲滿足「名稱」文本框後):麻煩與AngularJS自動標籤
var app = angular.module('plunker', []);
app.directive('autoTabTo', [function() {
return {
restrict: "A",
link: function (scope, el, attrs) {
el.bind('keyup', function(e) {
if (this.value.length === this.maxLength) {
var element = document.getElementById(attrs.autoTabTo);
if (element)
element.focus();
}
});
}
}
}]);
這是我的HTML(我的自定義指令):
<customtextfield autoTabTo="Variant.Specs.Title" ng-maxlength="20" customfield="Variant.Specs.Name"></customtextfield>
<customtextfield ng-maxlength="25" customfield="Variant.Specs.Title"></customtextfield>
你碰巧知道我做錯了什麼?
你太棒了!這個解決方案完美無缺 – JD06
semeone粘貼內容時如何使其工作? – alexislg