1
也许有人可以帮助我解决这个问题。自定义属性没有绑定的绑定属性
我似乎无法将回调绑定到customAttribute。 这里去一些代码
import {inject, customAttribute, bindable} from 'aurelia-framework';
import 'typeahead';
@customAttribute('typeahead')
@inject(Element)
export class Typeahead {
@bindable minLength = 0;
@bindable highlight = true;
@bindable substringMatcher = null;
constructor(element) {
this.element = element;
}
attached() {
var self = this;
$(self.element).typeahead({
hint: true,
highlight: self.highlight,
minLength: self.minLength
},
{
name: 'query',
source: (query) =>
{
console.log(self.substringMatcher);
if(self.substringMatcher){
self.substringMatcher(query);
}
}
});
}
}
我一直在试图分配在几个方面substringMatcher绑定回调,但物业始终是空
<input typeahead="substringMatcher.bind: search" class="form-control typeahead">
<input typeahead="substringMatcher: search" class="form-control typeahead">
<input typeahead="substringMatcher: this.search" class="form-control typeahead">
任何想法,为什么?