How to remove empty todo item


#1

i have some problem in my todo app whenever enter button clicking it showing empty new todo how to prevent this emty value plz help me this is my code…

//name: ‘’,

actions: {

  newTodo(name){
    let k = this.get('name');
    console.log(k);
    //let name = this.get('name');
    //if (name.length = 0) {
      //return;
    //}
    this.store.createRecord('todo',{
      name: name,
      isCompleted: false,
    }).save({

    });

#2

you was so close here:

//if (name.length = 0) {
  //return;
//}

Just restore your default value for name and compare for the empty string:

if (this.get('name') === '') {
  return;
}

And please, pay attention to equal expressions - in your case it was assignment, not comparison.