2016-09-27 6 views

답변

0

대신 :

save() { 
    if(this.todoItem != "" && this.todoText != "") { 
     this.todoList.push(this.todoItem); 
     localStorage.setItem("todol", JSON.stringify(this.todoList)); 
     this.nav.pop(); 
    } 
} 

은 내가 같이 보일 것이다 로컬 스토리지 JSON으로 누르면 ToDoItem을하고 todoText 그렇게 연결하려면 일반 todoItem을 목록에 푸시하면 표시된대로 필요한 패턴으로 객체를 만들 수 있습니다.

save() { 
    if(this.todoItem != "" && this.todoText != "") { 

     this.todoList.push({"todoItem":this.todoItem , "todoText":this.todoText}); 
     localStorage.setItem("todol", JSON.stringify(this.todoList)); 
     this.nav.pop(); 
    } 
} 
+0

이 오류를 무시해야합니까? 'Argument of type'{ "todoItem": string; "todoText": 문자열; } ''string '유형의 매개 변수에 할당 할 수 없습니다? – DaimCho

+0

어쩌면? 'this.todoList.push ({ "todoItem": this.todoItem, "todoText": this.todoText} : any); ' – sneeky

+0

@sneeky now' ','expected.' – DaimCho

관련 문제