【发布时间】:2023-01-06 21:34:18
【问题描述】:
This is the model where I import the uuid pack
import * as uuid from "uuid";
export class Note {
id: string;
constructor(public title: string, public content: string) {
this.id = uuid.v4();
}
}
in the component class :
import { ActivatedRoute, ParamMap } from "@angular/router";
import { Component, OnInit } from "@angular/core";
export class EditNoteComponent implements OnInit {
notes: Note[]
constructor(private activateRouter: ActivateRouter)
ngOnInit(): void {
this.activeRoute.paramMap.subscribe((paramMap: ParamMap) => {
const idParam = paramMap.get("id");
console.log(idParam);
});
}
and in the HTML file where I put the link so when the user clicks the notecard it should give me a unique id something like (9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d) but then console only show undefine!!!
<div class="noteContainer">
<div class="notes-lists">
<a [routerLink]="[note.id]" *ngFor="let note of notes">
<app-note-cards [note]="note"></app-note-cards>
</a>
</div>
</div>
【问题讨论】:
标签: angular typescript angular-ui-router syntax-error