Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

273
Views
How do I pass in a property into a link to a component in Angular

I have this link in my app.component.html...

<a [routerLink]="['system-administration/error-management']">Error Management</a>

I want to be able to pass in a title property into a link on the app component to another component that that component would display on its html page like this...

<h1>{{ title }}</h1>

I tried doing this...

<a [routerLink]="['system-administration/error-management']" [test]="Error Management">Error Management</a>

But that didn't work.

The error I got when I did ng serve was this...

Can't bind to 'test' since it isn't a known property of 'a'

I know I can create a global file and put all the properties in there, then import that global file into each component to access the property I want that way, but I think it would be more succinct if I were able to simply pass in a property where there is a link to a component.

Is this possible in Angular 11?

Thanks in advance!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

you can use the string in the url params on the other component;

import {Router, ActivatedRoute, Params} from '@angular/router';
import {OnInit, Component} from '@angular/core';

@Component({...})
export class MyComponent implements OnInit {

title: string;

  constructor(private activatedRoute: ActivatedRoute) {}

  ngOnInit() {
    this.activatedRoute.params.subscribe(params => {
        const message = params[0];
        this.title = message;
      });
  }

}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!