Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4828

[Guide] Require empty check?

$
0
0

@pcjpcj2 wrote:

I am following ember.js 2.3.0 guide.

now I read and code autocomplete method. https://guides.emberjs.com/v2.3.0/tutorial/autocomplete-component/

In this page, app/controller/index.js make undefined error when empty input string.

I don't want to leave it.

So.

is it right code to solve? I find Ember.isEmpty().

export default Ember.Controller.extend({
  filteredList: null,
  actions: {
    autoComplete(param) {
      if(param !== "") {
        this.store.query('rental', {city: param}).then((result) => {
          this.set('filteredList',result);
        });
      }
      else {
        let filteredList = this.get('filteredList');
        if(Ember.isEmpty(filteredList)) {
          return;
        }
        console.log();
        this.set('filteredList').clear();
      }
    },
    search(param) {
      if(param !== "") {
        this.store.query('rental', {city: param}).then((result) => {
          this.set('model',result);
        });
      }
      else {
        let model = this.get('model');
        if(Ember.isEmpty(model)){
          return;
        }
        this.set('model').clear();
      }
    }
  }
});

I want to know someone who have elegant solution.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4828

Trending Articles