2015-07-21 162 views
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"> 

任何想法,爲什麼?

回答

3

錯誤的情況下,在屬性...

這工作: <input typeahead="substring-matcher: search" class="form-control typeahead">