@@ -35,11 +35,16 @@ angular.module("firebase").factory("angularFire", ["$q", "$parse", "$timeout",
3535// The `AngularFire` object that implements implicit synchronization.
3636function AngularFire ( $q , $parse , $timeout , ref ) {
3737 this . _q = $q ;
38- this . _fRef = ref ;
3938 this . _parse = $parse ;
4039 this . _timeout = $timeout ;
4140 this . _initial = true ;
4241 this . _remoteValue = false ;
42+
43+ if ( typeof ref == "string" ) {
44+ throw new Exception ( "Please provide a Firebase reference instead " +
45+ "of a URL, eg: new Firebase(url)" ) ;
46+ }
47+ this . _fRef = ref ;
4348}
4449AngularFire . prototype = {
4550 // This function is called by the factory to create a new 2-way binding
@@ -186,6 +191,11 @@ AngularFire.prototype = {
186191angular . module ( "firebase" ) . factory ( "angularFireCollection" , [ "$timeout" ,
187192 function ( $timeout ) {
188193 return function ( collectionRef , initialCb ) {
194+ if ( typeof collectionRef == "string" ) {
195+ throw new Exception ( "Please provide a Firebase reference instead " +
196+ "of a URL, eg: new Firebase(url)" ) ;
197+ }
198+
189199 // An internal representation of a model present in the collection.
190200 function angularFireItem ( ref , index ) {
191201 this . $ref = ref . ref ( ) ;
@@ -411,7 +421,7 @@ angular.module("firebase").factory("angularFireAuth", [
411421 }
412422
413423 return {
414- // Initializes the authentication service. Takes a Firebase URL and
424+ // Initializes the authentication service. Takes a Firebase reference and
415425 // an options object, that may contain the following properties:
416426 //
417427 // * `scope`: The scope to which user authentication status will be
@@ -426,9 +436,14 @@ angular.module("firebase").factory("angularFireAuth", [
426436 // `firebase-simple-login.js` file by default. If this value is set to
427437 // false, this requirement is waived, but only custom login functionality
428438 // will be enabled.
429- initialize : function ( url , options ) {
439+ initialize : function ( ref , options ) {
430440 var self = this ;
431441
442+ if ( typeof ref == "string" ) {
443+ throw new Exception ( "Please provide a Firebase reference instead " +
444+ "of a URL, eg: new Firebase(url)" ) ;
445+ }
446+
432447 options = options || { } ;
433448 this . _scope = $rootScope ;
434449 if ( options . scope ) {
@@ -462,7 +477,7 @@ angular.module("firebase").factory("angularFireAuth", [
462477 }
463478
464479 // Initialize user authentication state to `null`.
465- this . _ref = new Firebase ( url ) ;
480+ this . _ref = ref ;
466481 if ( options . simple === false ) {
467482 updateExpression ( this . _scope , this . _name , null , function ( ) { } ) ;
468483 return ;
0 commit comments