When I am running ng build -prod I am getting the following warning.
Warning: Can't resolve all parameters for UsersPermissionsService in C:/SourceControl/Test.Client/src/app/shared/users/users-permissions.service.ts: (?, ?, ?). This will become an error in Angular v5.x
Warning: Can't resolve all parameters for UsersPermissionsService in C:/SourceControl/Test.Client/src/app/shared/users/users-permissions.service.ts: (?, ?, ?). This will become an error in Angular v5.x
My code is the following:
import { Injectable } from '@angular/core';
@Injectable()
export class UsersPermissionsService {
public USERS_CREATE_PERMISSION: string = '';
public USERS_UPDATE_PERMISSION: string = '';
public USERS_DELETE_PERMISSION: string = '';
constructor(public UsersCreatePermission: string,
public UsersUpdatePermission: string,
public UsersDeletePermission: string) {
this.USERS_CREATE_PERMISSION = UsersCreatePermission;
this.USERS_UPDATE_PERMISSION = UsersUpdatePermission;
this.USERS_DELETE_PERMISSION = UsersDeletePermission;
}
}
@Injectable()
export class UserModulePermissionsService extends UserPermissionsService {
constructor() {
super("ClientsCreate",
"ClientsEdit",
"ClientsDelete");
}
}
@Component({
templateUrl: './users-permissions.component.html',
providers: [UsersPermissionsService]
})
export class UsersPermissionsComponent {
constructor(public usersPermissionsService: UsersPermissionsService) {
}
}
and in my lazy loaded module I have:
providers: [
{ provide: UsersPermissionsService, useClass: UserModulePermissionsService }
]
Now that angular 5 is out I will need to update and as the message says this warning will become an error.
Don't understand what is really the problem here.
Remove the @Injectable
decorator from the base class. You should only include that decorator (or any decorator for that matter) on classes that Angular should instantiate directly (and while doing that also resolve their constructor parameters using the injector).
Since it is obvious that in your case the base class is not to be instantiated by angular directly (it has constructor parameters which are not known by the injector), you should remove the decorators from it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With