javascript - AuglarFire Authenticating With Routers throw unknown provider error -


so following firebase doc here authentication routers. instead, use ionic / ui-router , has abstract view , actual view controller. here structure:

.state('auth', {   url: "/auth",   abstract: true,   templateurl: "app/auth/auth.html",   resolve: {     "currentauth": ["auth", function(auth){       // $waitforauth returns promise resolve waits complete       return auth.$waitforauth();     }]   } }) .state('auth.signin', {   url: '/signin',   views: {     'auth-signin': {       templateurl: 'app/auth/auth-signin.html',       controller: 'signinctrl'     }   } }) .state('home', {   cache: false,     abstract: true,     url: "/home",     templateurl: "app/home/home.html",   controller: 'hometabctrl',   resolve: {     "currentauth": ["auth", function(auth){       // $requireauth returns promise resolve waits complete       // if promise rejected, throw $statechangeerror (see above)       return auth.$requireauth();     }]   } })  .state('home.courses', {   cache: false,   url: "/courses",   views: {     "tab-courses": {       templateurl: "app/home/courses.html",       controller: "coursectrl"     }   } }) 

so works fine. when go home.courses without logging in, redirect auth.signin. want currentauth return object/promise inside signinctrl. when user logged in, if go auth.signin state, redirect them home.courses instead. follow doc instruction inject currentauth in controller so:

(function () { 'use strict'; angular.module("myapp").controller('signinctrl', ['currentauth', '$scope', '$rootscope', signinctrl]);  function signinctrl(currentauth, $scope, $rootscope){     console.log (currentauth); }  })(); 

it throw error:

error: [$injector:unpr] unknown provider: currentauthprovider <- currentauth <- signinctrl

i did same thing docs example , try currentauth promise object (in order use if statement redirect user home.courses if currentauth not null). not work :( please firebase team.

update:

according kato, not able access currentauth promise. conventional way see if user logged in if in route /auth/signin/ , redirect them /home/courses/ route?

the error pretty informative; routes 101 , has been covered dozens of times on stack overflow. key here understanding currentauth not service or module (you've attempted include module , service here), injected resolve method when specific route invoked.

currentauth therefore not available /signin path, since there no resolve route. it's available "home" route because of resolve:

  resolve: {     "currentauth": ["auth", function(auth){ 

thus, can't use data in /signin unless create resolve route injects there, should superfluous since send them /signin if authdata null.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -