Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. // parent component
  2.  
  3. @Component({
  4. selector : 'node-display',
  5. template : `
  6. <router-outlet [node]="node"></router-outlet>
  7. `
  8. })
  9.  
  10. export class NodeDisplayComponent implements OnInit {
  11.  
  12. node: Node;
  13.  
  14. ngOnInit(): void {
  15. this.nodeService.getNode(path)
  16. .subscribe(
  17. node => {
  18. this.node = node;
  19. },
  20. err => {
  21. console.log(err);
  22. }
  23. );
  24. }
  25.  
  26. export class ChildDisplay implements OnInit{
  27.  
  28. @Input()
  29. node: Node;
  30.  
  31. ngOnInit(): void {
  32. console.log(this.node);
  33. }
  34.  
  35. }
  36.  
  37. Can't bind to 'node' since it isn't a known property of 'router-outlet'.
  38.  
  39. 1) Grab the "node" data from the server, from within the parent component
  40. 2) Pass the data I have retrieved from the server into the child router-outlet
  41.  
  42. @Injectable()
  43. export class SharedService {
  44.  
  45. sharedNode = {
  46. // properties, e.g
  47. //id: '' and so on...
  48. };
  49. }
  50.  
  51. this.sharedService.sharedNode = this.node;
  52.  
  53. node: Node;
  54.  
  55. ngOnInit() {
  56. this.node = this.sharedService.sharedNode;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement