Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Angular : pass data to component loaded via route

import {ActivatedRoute, Data} from "@angular/router";

const routes: Routes = [
	{path: 'developer', component: EmployeeComponent, data: {emp_type: 'developer'}},
    {path: 'tester', component: EmployeeComponent, data: {emp_type: 'tester'}},
    {path: 'analyst', component: EmployeeComponent, data: {emp_type: 'analyst'}}
];

class EmployeeComponent {
	constructor(private route: ActivatedRoute) {}

    ngOnInit() {
      this.data_subscription = this.route
        .data
        .subscribe(data: Data => 
          console.log('Employee type passed via route is ' + data.emp_type)
        );
    }

    ngOnDestroy() {
      this.data_subscription.unsubscribe();
    }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: localStorage check 
Javascript :: Literal string with a variable inserted 
Javascript :: react-map-multidimensional-array 
Javascript :: buffer to base 64 online 
Javascript :: javascript array list to each single value 
Javascript :: how to reload page with router next js 
Javascript :: how to send multiple values in event in javascript 
Javascript :: Total shopping amount from an object in javascript 
Javascript :: react-tournament-ready 
Javascript :: jboss-ejb-client.propeties exampe de configuration 
Javascript :: if condition in jasper expression editor 
Javascript :: tour-app-api 
Javascript :: regex expression for password uppercase lowercase specil character , number in js 
Javascript :: common library for .net and node js for encryption 
Javascript :: Falsy Bouncer 
Javascript :: get image height Jimp nodejs 
Javascript :: how to do multi ban discord.js 
Javascript :: Creates an Express application 
Javascript :: Cache and return requests 
Javascript :: kube allow pod deployment on master node 
Javascript :: create immutable array in javascript 
Javascript :: vs code javascript type check 
Javascript :: comment creer des switch en react js 
Javascript :: key index split 
Javascript :: <xsl:apply-templates select node text subnodes all 
Javascript :: botstrap 5 
Javascript :: js decrypt online 
Javascript :: ES2022 - Top-level await modules 
Javascript :: acced to unknown obkect key js 
Javascript :: jit and aot 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =