'对象'类型的[object Object]'。 NgFor仅支持绑定到诸如Arrays之类的Iterables。 uncatachable

时间:2017-12-12 03:02:50

标签: angular ionic-framework

我刚开始。我想要解决这个问题但我做不到。看看,到处重新搜索。我认为自己有义务提问。我已经阅读了有关该主题的所有主题,但我不知道如何解决我的问题。我希望你能帮助我,尝试一切。

我正在使用ionic3 - node.js 8.7:

Slide7Page.html

  <ion-list>
    <ion-item-sliding *ngFor="let todo of todos | async">
      <ion-item>
        {{ todo.text }}
      </ion-item>
      <ion-item-options side="right">
        <button ion-button color="danger" (click)="removeTodo(todo._id)">
        <ion-icon name="trash"></ion-icon>
        Delete
      </button>
    </ion-item-sliding>
  </ion-list>`

Slide7.ts

export class Slide7Page {
todos: Observable <any>;
constructor(public navCtrl: NavController, public navParams: NavParams, public todoService: TodoServiceProvider, public alertCtrl: AlertController, public toastCtrl: ToastController) {
this.loadTodos();
}

loadTodos() {
 this.todos = this.todoService.getTodos();
 }

}

待办事项-service.js

public getTodos() {
return this.http.get (this.apiUrl + 'todos')}

待办事项-routes.js

app.get('/todos', (req, res) => {
Todo.find({}, (err, todos) => {
if (err)  {
return res.json({ success: false, message: 'Error while creating Todo', error: err });
 }

res.status(200).send({ success: true, result: todos });
});
});

JSON

{

"success": true,

"result": [

    {

        "_id": "5a2c488afc7dd1069841ead2",

        "created_at": "2017-12-09T20:33:14.294Z",

        "text": "Mi Primer TODO",

       "__v": 0

    }

]

}

0 个答案:

没有答案