Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/461.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ember.js/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用Ember.js自动完成_Javascript_Ember.js_Handlebars.js - Fatal编程技术网

Javascript 使用Ember.js自动完成

Javascript 使用Ember.js自动完成,javascript,ember.js,handlebars.js,Javascript,Ember.js,Handlebars.js,我一直没能弄明白这一点 我想构建一个自动完成框,根据搜索结果显示联系人列表。我目前为用户提供此控制器: App.UsersController = Ember.ArrayController.extend({ sortProperties: ['firstName'], sortAscending: true, isCreateUser: false, sortByDigital: false, sortByPhys

我一直没能弄明白这一点

我想构建一个自动完成框,根据搜索结果显示联系人列表。我目前为用户提供此控制器:

App.UsersController = Ember.ArrayController.extend({
        sortProperties: ['firstName'],
        sortAscending: true,
        isCreateUser: false,
        sortByDigital: false,
        sortByPhysical: false,
        sortDisplayAll: true,
        createUser: function() {
            this.set('isCreateUser', true);
        },

        motoDigital: function() {
            this.set('sortByDigital', true);
            this.set('sortByPhysical', false);
            this.set('sortDisplayAll', false);
        },
        motoPhysical: function() {
            this.set('sortByDigital', false);
            this.set('sortDisplayAll', false);
            this.set('sortByPhysical', true);
        },
        displayAll: function() {
            this.set('sortByDigital', false);
            this.set('sortDisplayAll', true);
            this.set('sortByPhysical', false);
        },
        searchText: null,

        searchResults: function() {
            var searchText = this.get('searchText');
            if(!searchText) { return; }

            var regex = new RegExp(searchText, 'i');
            return this.get('firstName').filter(function(firstName) {
                return firstName.match(regex);
            });
        }.property('searchText')
    });
  • 相关部分是
    搜索文本
    搜索结果
然后我将此作为模板(希望不会太长):


{{{#linkTo'users.new'class=“btn btn primary createUser”}新联系人{{/linkTo}


    非常感谢您的帮助

    搞清楚什么是错的有点难。也许可以尝试发布一个jsbin

    我注意到的一件事是,
    searchText
    不绑定到
    value
    。你可能想把它改成

    {{input type="text" valueBinding=searchText placeholder="Search..."}}
    
    {{input type="text" valueBinding=searchText placeholder="Search..."}}