jsHint投掷' Firebase'未定义警告

时间:2014-07-22 05:47:53

标签: angularjs firebase jshint angularfire

如何正确定义Firebase,以便jshint停止发出哔哔声。

我的代码正在运行......只是jshint很烦恼

app.js

 angular
  .module('morningharwoodApp', [
    'firebase',
    'ngAnimate',
    'ngCookies',
    'ngResource',
    'ngRoute',
    'ngSanitize',
    'ngTouch'

  ])

main.js

angular.module('morningharwoodApp')
  .controller('MainCtrl', function ($scope, $firebase) {
    // var Firebase;
    var pageRef = new Firebase('https://morningharwood.firebaseIO.com/page');
    // var pageRef = new Firebase('https://morningharwood.firebaseIO.com/page');


    //init
    $scope.pages = $firebase(pageRef);
    $scope.newPage = {
        title: '',
        slug: '',
        url: '',
        desc: '',
        active: false,
        template: [
            {
                type: ''
            }
        ],
        img: '',
        dateCreated: '',
        dateUpdated: ''

    };

    //CRUD

    //add
    $scope.addPage = function() {
        $scope.pages.$add($scope.newPage);
        $scope.newPage = '';
    };
  });

enter image description here

2 个答案:

答案 0 :(得分:10)

您还可以在jshint.rc中执行以下操作

 "jshint_options":
    {
        "predef": {
            "Firebase": false
        }
     }

答案 1 :(得分:3)

由于Firebase应该添加到全局对象(窗口),因此您可以使用$window服务:

.controller('MainCtrl', function ($firebase, $scope, $window) {
    var pageRef = new $window.Firebase('...');
相关问题