如何使用like this实现angular-selectize的某些内容?
我在收听按键事件时遇到问题。该示例使用selectize.$control_input.on("keydown")
,但在角度选择中似乎没有任何此类内容。
答案 0 :(得分:0)
angular-selectize公开onInitialize
中的原生Selectize实例:
onInitialize: function(selectize)
{
$scope.selectize = selectize;
}
例如。
答案 1 :(得分:0)
您也可以通过选择插件来完成。
最后看到事件的注册。
/**
* Plugin: "dropdown_header" (selectize.js)
* Copyright (c) 2013 Brian Reavis & contributors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at:
* http://www.apache.org/licenses/LICENSE-2.0
*
*/
Selectize.define('dropdown_header', function(options) {
var self = this;
options = $.extend({
title : 'Untitled',
headerClass : 'selectize-dropdown-header',
titleRowClass : 'selectize-dropdown-header-title',
labelClass : 'selectize-dropdown-header-label',
closeClass : 'selectize-dropdown-header-close',
html: function(data) {
return (
'<div class="' + data.headerClass + '">' +
'<div class="' + data.titleRowClass + '">' +
'<span class="' + data.labelClass + '">' + data.title + '</span>' +
'<a href="javascript:void(0)" class="' + data.closeClass + '">×</a>' +
'</div>' +
'</div>'
);
}
}, options);
self.setup = (function() {
var original = self.setup;
return function() {
original.apply(self, arguments);
self.$dropdown_header = $(options.html(options));
self.$dropdown.prepend(self.$dropdown_header);
this.$control.on('keydown', function(e) {
//alert('A keypess $control!');
});
this.$wrapper.on('keydown', function(e) {
//alert('A keypess $wrapper!');
});
this.$input.on('keydown', function(e) {
alert('A keypess $input!');
});
};
})();
});