angular - 如何在 Angular2 路由中传递服务功能
问题描述
如何在路径中连接“TTENCommonService.getRole()”?在 getRole() 事件中,我返回了字符串值。
应用程序路由.module.ts
import { TTENCommonService } from './tten-common/services/tten-
common.service';
const routes: Routes = [
{
path: '', redirectTo: '/dashboard '+ TTENCommonService.getRole(), pathMatch: 'full'
}
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
解决方案
因为是课外。你可以打电话给新的运营商。请看下面的代码。
希望能帮助到你。
const routes: Routes = [
{
path: '', redirectTo: '/dashboard '+ new TTENCommonService().getRole(), pathMatch: 'full'
}
];
推荐阅读
- node.js - node.js 不和谐机器人使用输入作为机器人输出和反应
- python - 将 DataFrame 插入雪花时,snowflake.connector.errors.ProgrammingError: 001003 (42000)
- javascript - 尝试在我的业务关闭时更改链接的路径
- numpy - 如何在 Python 中将点 (x,y,z) 投影到 (x,y) 上?
- c# - POST 控制器操作方法的 LIST 返回计数 = 0
- python - 如何保存从 Django 模型中的模板获取的对象列表?
- c++ - 如何从 C++ 代码中检索 QML 的 TextField 中的文本?
- apache - 无法使用 Ubuntu/Apache 从 .NET Core Web 应用程序加载静态文件
- java - 如何限制 ArrayList 的大小?
- node.js - 连接 Mongodb 集群时出错 [MongoNetworkError: failed to connect to server [cluster0-shard-00-02-jm5fl.mongodb.net:27017]