http://plnkr.co/edit/G43dqi8H4dn6d8oXdvyy
我认为以下问题是由于我加载firebase数据的方式,因为将数据调用放在setTimeouts中会对开发服务器产生影响,但同样对生产服务器没有帮助,即使超时也是如此曲折的方式。
在gh-pages上完美地运行开发版本。我已经使用http-server测试了生产版本并且可以使用。但是,一旦gh-pages得到它,就会在var indexRef = new Firebase(refString);
上抛出以下错误:
错误:新的Firebase失败:第一个参数必须是有效的firebase 网址和路径不能包含"。","#"," $"," [",或"]"。
这里是gh-pages link和the repo, it's small just one partial-view/route/controller
能够重现使用Firebase自己的托管在gh页面上看到的错误。
angular.module('metal01').controller('LandingCtrl', ['$scope', '$firebase', 'Firebase', '$window', '$location' , function($scope, $firebase, Firebase, $window, $location){
// get host url and format to match db index key
var location = $location.host();
location.toLowerCase().replace(/'+/g, '').replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "-").replace(/^-+|-+$/g, '');
// getting firebase reference for host url index
var refString = "https://tezt.firebaseio.com/metal/index/domains/"+ location;
// This is throwing error!
var indexRef = new Firebase(refString);
var indexSync = $firebase(indexRef);
var indexArray = indexSync.$asArray();
var indexObject = indexSync.$asObject();
setTimeout(function(){
// create firebase objects in timeout to avoid undefined while loading.
var domainRef = 'https://tezt.firebaseio.com/metal/domains/'+indexObject.$value;
var ref = new Firebase(domainRef);
var sync = $firebase(ref);
var mediaSync = $firebase(mediaRef);
$scope.data = sync.$asObject();
$scope.list = sync.$asArray();
$scope.media = mediaSync.$asArray();
$scope.height = $window.innerHeight;
$scope.location = $location.host();
},2000);
var mediaRef = new Firebase("https://tezt.firebaseio.com/metal/media/");
}]);