我想从路由参数中获取 id 但它返回 null 作为值。
app.component.ts:
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit {
constructor(private route: ActivatedRoute) { }
ngOnInit(){
const id = this.route.snapshot.paramMap.get('idC');
console.log(id);
}
Run Code Online (Sandbox Code Playgroud)
路由.ts:
{ path: 'profile/:idC', component: AccountComponent }
Run Code Online (Sandbox Code Playgroud)
app.component 上代码的目的是因为我在 app 上使用导航栏,所以当用户连接时,预期的结果是从路由中获取 id,以便导航栏显示“欢迎用户 1”。任何解决方案?
我一直在搜索和阅读有关如何将mysql数据导入ES的文档,并通过创建logstash文件并每分钟运行它来获得最佳解决方案。但最后,与我的要求相比,它效率不高(我必须在logstash中的每个表上运行每个查询,这是不切实际的)。
每次用户处理我的应用程序时(平台上有很多用户),我都必须将整个 MySQL 数据库导入 Elasticsearch,包括映射、表关系和数据。
我已经阅读过此链接,但它对我没有帮助。有什么建议 ?谢谢
我正在尝试使用一个* ngFor循环两个数组,但它在浏览器上未显示任何元素。我在下面的HTML文件示例中,也在组件文件中初始化了数组。
HTML档案:
<tbody *ngIf="feedbacks.length">
<ng-container *ngFor="let fd of feedbacks;let res of results;let i=index">
<tr>
<td>{{ i }}</td>
<td>{{fd}}</td>
<td colspan="2">
<ul>
<div *ngFor="let obj of res">
<td>Score: {{res.score}}</td>
<td>Emotion: {{res.tone_name}}</td>
</div>
</ul>
</td>
</tr>
</ng-container>
</tbody>
Run Code Online (Sandbox Code Playgroud)
打字稿文件:
results = [];
feedbacks = [];
ngOnInit(){
this.feedbacks = ["Le système est trop lent ", "Le top! Un exemple d'excellence.", "C'est quoi ce bordel !"];
this.results = [
[{score: 0.535632, tone_id: "anger", tone_name: "Colère"}],
[{score: 0.633569, tone_id: "anger", tone_name: "Colère"},
{score: 0.506763, …Run Code Online (Sandbox Code Playgroud)