angular - 将布尔变量传递到路由器出口
问题描述
我有这个代码:
应用组件.ts
public euskera: boolean;
ngOnInit(): void {
this.euskera=false;
}
setEuskera(){
this.euskera=true;
}
setCastellano(){
this.euskera=false;
}
想将 euskera 的值传递给路由器插座中的孩子:
app.component.html
<div id="content">
<router-outlet [euskera]="euskera">
</router-outlet>
</div>
home.component.ts
public title: string
public title_eus: string;
@Input() euskera:boolean=false;
home.component.html
<div *ngIf="euskera">
<h1>{{title_eus}}</h1>
</div>
<div *ngIf="!euskera">
<h1>{{title}}</h1>
</div>
如何通过路由器插座传递变量的值以从我的所有组件中获取它并让 IF 进行匹配?
解决方案
您可以尝试使用角度定位
编辑:或调用不同的组件...
推荐阅读
- node.js - http包在flutter中从api获取错误的图像url
- azure - 管道使用相同的 yaml 但部署到不同的订阅
- xml - 如何使用 XSLT 检查 XML 在不同节点中是否具有相同的值?
- node.js - sh: 1: node-gyp-build: Permission denied and npm ERR! 代码 ELIFECYCLE npm 错误!错误号 126
- reactjs - 当我连接另一台电脑时,React App 出现错误
- postgresql - 如何在 sql 中创建基本循环计算以避免执行 200 多个连接
- mongodb - MongoDb:无法优化管道:原因:无法从 BSON 类型 javascript 转换为 Date
- python - 无法使用 httpclientlibrary 在 lambda 函数中发送电子邮件
- django - 在 Django 模板中渲染熊猫的数据框
- nuxt.js - Vercel 上的 NUXT SSR(现在是时代)。如何部署?