【问题标题】:Angular2 - Materialize css autocomplete dropdownAngular2 - 物化 css 自动完成下拉菜单
【发布时间】:2018-11-28 05:23:47
【问题描述】:

我在 angularjs 中使用物化 css 自动完成功能,但不知道如何映射到 json 响应。

//students是带有属性id、name、email、address的接口

students: Student[];

ngOnInit() {
    this._studentService.getAllActiveStudents().subscribe(data => {
    this.students = data;
});

如何将json响应(data:)替换成服务响应this.students

$(document).ready(function(){
    $('input.autocomplete').autocomplete({
    data: {
        "Apple": null,
        "Microsoft": null,
        "Google": 'https://placehold.it/250x250'
    },
    });
});

【问题讨论】:

  • 我没有看到 AngularJS ...它是 Angular ...你的问题是错误的..
  • 你说得对,它是有棱角的。感谢您的指出。

标签: angular materialize


【解决方案1】:

使用实例,

const instance = $('input.autocomplete').autocomplete({
        data: {
            "Apple": null,
            "Microsoft": null,
            "Google": 'https://placehold.it/250x250'
        },
        });

然后

instance.updateData(<your object>);

实际上,我不确定您在哪里使用materilize $ (jquery)

我的使用:

this.inst = M.Autocomplete.init(this.element.nativeElement, {
      data: {},
      minLength: 1,
      limit: 1
    });

// update

this.inst.updateData({'ME': null});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-04-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-30
    • 2016-10-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多