Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // parent component
- @Component({
- selector : 'node-display',
- template : `
- <router-outlet [node]="node"></router-outlet>
- `
- })
- export class NodeDisplayComponent implements OnInit {
- node: Node;
- ngOnInit(): void {
- this.nodeService.getNode(path)
- .subscribe(
- node => {
- this.node = node;
- },
- err => {
- console.log(err);
- }
- );
- }
- export class ChildDisplay implements OnInit{
- @Input()
- node: Node;
- ngOnInit(): void {
- console.log(this.node);
- }
- }
- Can't bind to 'node' since it isn't a known property of 'router-outlet'.
- 1) Grab the "node" data from the server, from within the parent component
- 2) Pass the data I have retrieved from the server into the child router-outlet
- @Injectable()
- export class SharedService {
- sharedNode = {
- // properties, e.g
- //id: '' and so on...
- };
- }
- this.sharedService.sharedNode = this.node;
- node: Node;
- ngOnInit() {
- this.node = this.sharedService.sharedNode;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement