JsHint throwing "Firebase" undefined warning

how I correctly detect Firebase so jshint stops sounding.

My code works ... only jshint is annoying

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

+6
source share
2 answers

You can also do the following in jshint.rc

  "jshint_options": { "predef": { "Firebase": false } } 
+10
source

Since Firebase supposed to be added to the global object (window), you can use the $window service:

 .controller('MainCtrl', function ($firebase, $scope, $window) { var pageRef = new $window.Firebase('...'); 
+3
source

Source: https://habr.com/ru/post/972632/


All Articles