没有可绑定 属性 绑定的自定义属性
Custom Attribute not having a bindable property bound
也许有人可以帮我解决这个问题。
我似乎无法将回调绑定到 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 可绑定回调,但 属性 始终为 null
<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">
知道为什么吗?
属性大小写错误...
这有效:
<input typeahead="substring-matcher: search" class="form-control typeahead">
也许有人可以帮我解决这个问题。
我似乎无法将回调绑定到 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 可绑定回调,但 属性 始终为 null
<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">
知道为什么吗?
属性大小写错误...
这有效:
<input typeahead="substring-matcher: search" class="form-control typeahead">