【问题标题】:Exception while simulating the effect of invoking '/todos/update'模拟调用'/todos/update'的效果时出现异常
【发布时间】:2015-06-17 18:48:41
【问题描述】:

我正在使用 Angular-Meteor 构建一个 TODO 应用程序。我正在按照这里的教程进行操作: http://angularjs.meteor.com/tutorial/step_06

我在尝试访问单个待办事项时出错:

这是我的 app.js

Todos = new Mongo.Collection('todos');

if (Meteor.isClient) {
  var todo = angular.module('todo', ['angular-meteor', 'ui.router']);

  todo.config(['$urlRouterProvider', '$stateProvider', '$locationProvider', function($urlRouterProvider, $stateProvider, $locationProvider) {
    $locationProvider.html5Mode(true);

    $stateProvider
      .state('todos', {
        url: '/todos',
        templateUrl: 'todos-list.ng.html',
        controller: 'todoListController'
      })
      .state('todoDetails', {
        url: '/todos/:todoId',
        templateUrl: 'todo-details.ng.html',
        controller: 'todoDetailsController'
      });

    $urlRouterProvider.otherwise("/todos");

  }]);

  todo.controller('todoListController', ['$scope', '$meteor', function($scope, $meteor) {
    $scope.todos = $meteor.collection(Todos);

    $scope.addTodo = function(todo) {
      todo.date = new Date();
      $scope.todos.save(todo);
    };

    $scope.remove = function(todo) {
      $scope.todos.remove(todo);
    };

    $scope.clear = function() {
      $scope.todos.remove();
    };

  }]);

  todo.controller('todoDetailsController', ['$scope', '$stateParams','$meteor', function($scope, $stateParams, $meteor) {
    $scope.todoId = $stateParams.todoId;
    $scope.todo = $meteor.object(Todos, $stateParams.todoId);
  }]);

}

我的 index.html:

<head>
  <base href="/">
</head>

<body>
  <div ng-app="todo">
    <h1>
      <a href="/todos">Home</a>
    </h1>
    <div ui-view></div>
  </div>
</body>

我的待办事项列表.ng.html

<form>
  <label for="name">Name</label>
  <input type="text" id="name" ng-model="newTodo.name">
  <label for="priority">Priority</label>
  <input type="text" id="priority" ng-model="newTodo.priority">
  <button class="btn btn-primary" ng-click="addTodo(newTodo)">Add Todo</button>
</form>
<ul>
  <li ng-repeat="todo in todos track by $index">
    <a href="/todos/{{todo._id}}">{{todo.name}} {{todo.priority}} {{todo.date | date}}</a>
    <button class="btn btn-primary" ng-click="remove(todo)">Done</button>
  </li>
  <h4>Tasks to do: {{todos.length}}</h4>
</ul>
<button class="btn btn-primary" ng-click="clear()">Clear list</button>

还有 todo-details.ng.html

<h1>Your to do</h1>
<input type="text" ng-model="todo.name">
<input type="text" ng-model="todo.priority">

我不知道,我做错了什么,按照官方教程一步一步来,只是用 todo 替换各方,老实说。

有什么想法吗?

【问题讨论】:

    标签: javascript angularjs meteor


    【解决方案1】:

    原来这是 Meteor 本身造成的错误。

    我在Github 上创建了一个问题并已修复。

    【讨论】:

      猜你喜欢
      • 2017-09-27
      • 2015-11-13
      • 2016-09-23
      • 2014-10-12
      • 1970-01-01
      • 2018-12-11
      • 1970-01-01
      • 2017-01-03
      • 1970-01-01
      相关资源
      最近更新 更多