0

I am using materialize css autocomplete feature in angularjs but don't know how to map into json response.

//students is the interface with property id, name, email, address

students: Student[];

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

How to replace json response (data:) into service response this.students

$(document).ready(function(){
    $('input.autocomplete').autocomplete({
    data: {
        "Apple": null,
        "Microsoft": null,
        "Google": 'https://placehold.it/250x250'
    },
    });
});
2
  • I don't see AngularJS ... it's Angular ... Your question it's wrong.. Commented Jun 19, 2018 at 10:18
  • You are right it is angular. Thanks for pointed out. Commented Jun 19, 2018 at 10:25

1 Answer 1

0

Use the instance,

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

and after that

instance.updateData(<your object>);

Actually, I'm not sure where the materilize here as you is used $ (jquery)

My using:

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

// update

this.inst.updateData({'ME': null});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.