【发布时间】:2014-09-12 19:49:33
【问题描述】:
如何正确定义 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 = '';
};
});
【问题讨论】:
-
您可以在文件顶部添加
/*global Firebase */。 -
有趣...在顶部添加那个简单的注释修复了它。 Jshint 必须扫描 cmets?
-
您也可以将其添加为 Angular 常量,然后在需要的地方注入
Firebase:/* global window:false */ angular.module('myApp').constant('Firebase', window.Firebase);
标签: angularjs firebase jshint angularfire