Pass data through <router-exit> using component interaction in angular2

I am trying to use this method to intercept changes to input properties using the installer to pass some data from the parent component to the child component and call the method in the child component when the value changes. my problem is that the child component is bound to the parent element <router-link>and when I try to pass data using:

parent_component.html:

<router-outlet [some_value] = "some_value"></router-outlet>

where some_value is the parameter I'm trying to pass from parent to child.

parent_component.ts:

public some_value: string;

and

parent_component.ts:

@Input()
  public set some_vale(number : string){
    this._some_value = number;
  }

however i get an error

: : "some_value", "router-outlet".

? <router-outlet>?

, .

+6
1

:

import {Injectable, EventEmitter} from "@angular/core";    

@Injectable()
export class DataService {
onGetData: EventEmitter = new EventEmitter();

getData() {
  this.http.post(...params).map(res => {
    this.onGetData.emit(res.json());
  })
}

:

import {Component} from '@angular/core';    
import {DataService} from "../services/data.service";       

@Component()
export class MyComponent {
  constructor(private DataService:DataService) {
    this.DataService.onGetData.subscribe(res => {
      (from service on .emit() )
    })
  }

  //To send data to all subscribers from current component
  sendData() {
    this.DataService.onGetData.emit(--NEW DATA--);
  }
}
+5

All Articles