我正在学习本教程,构建一个与firebase数据库连接的angularjs应用程序.我坚持第3章,我的应用程序应该使它初始连接到数据库.我有点觉得问题摆在我面前,因为我的命令提示符和jshint告诉我:
Running "jshint:all" (jshint) task app\scripts\controllers\posts.js line 0 col 0 Bad option: 'app'. line 8 col 1 'app' is not defined. app\scripts\services\post.js line 0 col 0 Bad option: 'app'. line 2 col 1 'app' is not defined. 6 problems Warning: Task "jshint:all" failed. Use --force to continue. Aborted due to warnings.
我的控制台给了我:
>Uncaught ReferenceError: app is not defined post.js >Error: [$injector:unpr] Unknown provider: PostProvider <- Post http://errors.angularjs.org/1.2.16/$injector/unpr?p0=PostProvider%20%3C-%20Post at http://localhost:9000/bower_components/angular/angular.js:78:12 at http://localhost:9000/bower_components/angular/angular.js:3705:19 at Object.getService [as get] (http://localhost:9000/bower_components/angular/angular.js:3832:39) at http://localhost:9000/bower_components/angular/angular.js:3710:45 at getService (http://localhost:9000/bower_components/angular/angular.js:3832:39) at invoke (http://localhost:9000/bower_components/angular/angular.js:3859:13) at Object.instantiate (http://localhost:9000/bower_components/angular/angular.js:3880:23) at http://localhost:9000/bower_components/angular/angular.js:7134:28 at link (http://localhost:9000/bower_components/angular-route/angular-route.js:913:26) at nodeLinkFn (http://localhost:9000/bower_components/angular/angular.js:6579:13)
为什么我的其他js文件看不到我的'app'全局声明?
(apps.js)
var app = angular.module('angNewsApp', [ 'ngAnimate', 'ngCookies', 'ngResource', 'ngRoute', 'ngSanitize', 'ngTouch' ])(post.js)
'use strict'; app.factory('Post', function ($resource){ return $resource('https://sizzling-fire-1990.firebaseio.com/posts/:id.json'); });**从教程中复制所有文件内容
撰写答案