首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >没有绑定属性绑定的自定义属性

没有绑定属性绑定的自定义属性
EN

Stack Overflow用户
提问于 2015-07-21 13:50:57
回答 1查看 396关注 0票数 1

也许有人能帮我解决这个问题。

我似乎无法将回调绑定到customAttribute。这是一些代码

代码语言:javascript
复制
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

代码语言:javascript
复制
<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">

知道为什么吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-07-21 14:20:15

关于属性的错误案例..。

这起作用了:<input typeahead="substring-matcher: search" class="form-control typeahead">

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31541052

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档