Can't resolve all parameters when using ng --prod

171 views
Skip to first unread message

Anthony Pri

unread,
Oct 23, 2018, 10:28:33 AM10/23/18
to Angular and AngularJS discussion
ERROR in : Can't resolve all parameters for AuthorizationGuard ./authorization.guard.ts: (?, [object Object]).  Not sure how to fix this.


import {ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot, CanActivateChild,RouterModule } from "@angular/router";
import {Observable} from "rxjs";
import * as _ from 'lodash';
import {Injectable} from "@angular/core";

@Injectable()
export class AuthorizationGuardSecureityimplements  CanActivateChild {


    canActivateChild(childRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean | Observable<boolean> | Promise<boolean> {
       throw new Error("Method not implemented.");
   }
   constructor(private allowedRoles:string[],
               private router:Router) {

    }


    canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
       this.router.navigate(['Home/index']);

    }

}



Sander Elias

unread,
Oct 26, 2018, 12:14:50 AM10/26/18
to Angular and AngularJS discussion
Hi Anthony,


constructor(private allowedRoles:string[], private router:Router) {}

The injector does not know what to inject for `string[]`. Don't declare private variables like that. define them on the class itself.

Regards
Sander

Anthony Pri

unread,
Oct 26, 2018, 9:37:39 AM10/26/18
to ang...@googlegroups.com
Define them on the class? do you have example. thanks

--
You received this message because you are subscribed to a topic in the Google Groups "Angular and AngularJS discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/b5OtWpct31o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.


--

Anthony Pri

unread,
Oct 26, 2018, 10:29:06 AM10/26/18
to ang...@googlegroups.com
I fixed it thanks.

On Fri, Oct 26, 2018 at 12:15 AM Sander Elias <sande...@gmail.com> wrote:
--
You received this message because you are subscribed to a topic in the Google Groups "Angular and AngularJS discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/b5OtWpct31o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages