AngularJS视图不显示Firebase数据

时间:2014-12-23 18:26:22

标签: javascript angularjs

我正在尝试使用AngularJS和Firebase构建一个简单的待办事项列表应用程序,并且我在将一个数据从Firebase显示到我的一个视图时出现问题。我在控制台中收到错误,这可能是数据未显示的原因。这是错误(实际上,一个只是一个警告):

Resource interpreted as Script but transferred with MIME type text/html: "http://localhost:8000/assets/js/controllers/taskcontoller.js".
taskcontoller.js:1 Uncaught SyntaxError: Unexpected token <
angular.js:10126 Error: [ng:areq] http://errors.angularjs.org/1.2.28/ng/areq?p0=TasksController&p1=not%20aNaNunction%2C%20got%20undefined
    at Error (native)
    at http://localhost:8000/assets/lib/angular/angular.min.js:6:450
    at Db (http://localhost:8000/assets/lib/angular/angular.min.js:19:106)
    at Ya (http://localhost:8000/assets/lib/angular/angular.min.js:19:193)
    at http://localhost:8000/assets/lib/angular/angular.min.js:67:405
    at link (http://localhost:8000/assets/js/lib/angular-route.min.js:7:248)
    at J (http://localhost:8000/assets/lib/angular/angular.min.js:54:373)
    at g (http://localhost:8000/assets/lib/angular/angular.min.js:47:256)
    at http://localhost:8000/assets/lib/angular/angular.min.js:46:377
    at http://localhost:8000/assets/lib/angular/angular.min.js:48:217

以下是视图:

<ul class="list col-sm-12 text-center">
    <li ng-repeat="task in activeTasks">
        <div class="item">
            <p>{{task.taskName}}</p>
        </div>
    </li>
</ul>

这是控制器:

myApp.controller('TasksController',
    function($scope, $firebase){
        var activeTasksRef = new Firebase('https://project-name.firebaseio.com/tasks/activeTasks');
        var completedTasksRef = new Firebase('https://project-name.firebaseio.com/tasks/completedTasks');

        var activeTasks = $firebase(activeTasksRef);
        var completedTasks = $firebase(completedTasksRef);

        $scope.activeTasks = activeTasks.$asObject();
        $scope.completedTasks = completedTasks.$asObject();

});

而且,这是App.js:

var myApp = angular.module('myApp',
    ['ngRoute', 'firebase', 'appControllers', 'ui.bootstrap']);

var appControllers = angular.module('appControllers', ['firebase']);

myApp.config(['$routeProvider',function($routeProvider) {
    $routeProvider.
        when('/active-tasks', {
            templateUrl: '/views/active-tasks.html',
            controller: 'TasksController',
        }).
        when('/completed-tasks', {
            templareUrl: '/views/completed-tasks.html',
            controller: 'TasksController',
        }).
        otherwise({
            redirectTo: '/active-tasks'
        });
}]);

我确实在html中定义了Angular:

<html lang="en" ng-app="myApp">

关于我做错的任何想法?

0 个答案:

没有答案