模拟调用' / todos / update'的效果时出现例外情况

时间:2015-04-12 11:08:03

标签: javascript angularjs meteor

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

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

error

这是我的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>

我的todo-list.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取代派对。

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

事实证明这是由Meteor本身造成的错误。

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