要解决"Angular 6: 在promise中未捕获的错误: 静态注入器错误(AppModule)[RoleGuardService]"错误,您可以尝试以下解决方法:
import { RoleGuardService } from './path/to/role-guard.service';
@NgModule({
providers: [
RoleGuardService
]
})
export class AppModule { }
import { RoleGuardService } from './path/to/role-guard.service';
constructor(private roleGuardService: RoleGuardService) { }
检查RoleGuardService的依赖项是否正确导入和注入。确保RoleGuardService没有依赖于未导入或未提供的服务或模块。
如果RoleGuardService依赖于其他服务,您还可以尝试将这些服务添加到providers数组中,以确保它们正确地提供给RoleGuardService。
如果您使用了懒加载模块,确保在懒加载模块中正确地导入和提供RoleGuardService。在懒加载模块的providers数组中提供RoleGuardService。
如果以上解决方法都没有解决问题,可以尝试清除Angular应用的缓存。您可以尝试删除node_modules文件夹并重新安装依赖项,然后重新构建和运行应用程序。
希望这些解决方法能帮助您解决问题。如果问题仍然存在,请提供更多的代码示例,以便我们能够更好地帮助您解决问题。