angularjs - AngularFire: how to set $location.path in onAuth()? -


I am creating an angular + firebase app with user authentication (0.8 with an angle).

I need to use on the author (orthos) event handler because I will provide multiple authentication paths, include social and want to avoid code duplication. Inside the OnAuth callback, I have to reset the location.path to '/'. Usually everything works well, but, if the pre-certified session ( & lt; F5 & gt; , for example), at $ scope $ Applied () me "Error: [$ rootScope: inprog] $ already running"
(If I do not use $. $ Apply (), Does not apply to location path area, and no page changes occur).

I suspect that I make some stupid mistakes, but I can not recognize it. ..

This is my workflow:

  app.controller ('AuthCtrl', function ($ radius, $ rootsecope, user) {var ref = new firebase (MY_FIREBASE_URL) )); $ Scope.init = function () {$ scope.users = []; User.all. $ BindTo ($ scope, 'user'). Then (function () {console.info ('$ scope.users binding:', $ Scope.users);})}} $ scope.login = function () {ref.authWithPassword ({email: $ scope.user. Email, password: $ scope.user.password,}, function {Err} {if (err) {console.error ('error during authentication:', mistake);}}); }; Ref.onAuth (function (authData) {if (authData) {console.info ('Login Success'); var $ rootScope.currentUser = $ scope.users [authData.uid]; $ location.path ('/'); $ Radius. $ Apply ();} and {console.info ('logout success');}}); }; App.factory ('user', function ($ firebase) {var ref = $ firebase (new firebase (MY_FIREBASE_URL + 'user')); return {all: referrals $ asObject ()};}); As a reference, I want to post the solution I received, and I'm currently adopting:  
  $ scope.init = function () {$ scope.params = $ RouteParams; $ Scope.debug = CFG.DEBUG; $ Scope.lastBuildDate = Lastbuildet; $ Scope.error = null; $ Scope.info = null; $ Scope.users = []; User.all $ bindTo ($ scope, 'users') Then (function () {// clock authentication event refAuth.onAuth (function (authData) {$ scope.auth (authData);})}}); ...}; ...  

Ie was enough to transfer the clock on the objectivity events from the firebug to users on the bindTo in the callback.


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

javascript - amcharts makechart not working -

java - Algorithm negotiation fail SSH in Jenkins -