Guest User

Untitled

a guest
Mar 21st, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. import { Component, Input, EventEmitter, Output } from '@angular/core';
  2.  
  3. @Component({
  4. selector: 'Menu',
  5. templateUrl: `
  6. <div>
  7. <button (click)="toggler()">MENU</button>
  8. <div id="left-menu" [hidden]="hidden">
  9. <ul>
  10. <li *ngFor="let item of items"><a (click)=displayMarkers(item.action)>{{ item.text }}</a></li>
  11. </ul>
  12. </div>
  13. </div>`,
  14. styleUrls: ['app.menu.css'],
  15. })
  16.  
  17. export class Menu {
  18.  
  19. @Output() pick = new EventEmitter<any>();
  20.  
  21. hidden: boolean = true;
  22. items: object[] = [
  23. {action: 'login', text: 'zaloguj się'},
  24. {action: 'halls', text: 'hale sportowe'},
  25. {action: 'sweemingPools', text: 'baseny'},
  26. ];
  27.  
  28. constructor() {}
  29.  
  30. toggler() {
  31. this.hidden = !this.hidden;
  32. };
  33.  
  34. displayMarkers(type:string){
  35. console.log('test1', type); //work correctly
  36. this.pick.emit(type); //won't work
  37. };
  38.  
  39. }
  40.  
  41. import { Component } from '@angular/core';
  42.  
  43. import { Menu } from './menu/app.menu';
  44. import { Map } from './map/app.map';
  45.  
  46. @Component({
  47. selector: 'app-root',
  48. templateUrl: `
  49. <div>
  50. <Menu (pick)="onPick($event)"></Menu>
  51. <div style="text-align:center">
  52. <h1>{{ title }}!</h1>
  53. </div>
  54. <Map></Map>
  55. </div>`
  56. ,
  57. styleUrls: ['app.css'],
  58. })
  59. export class App {
  60. title: string = 'My webapp';
  61.  
  62. onPick(event:string){
  63. console.log('test2', event); //nothing, won't work
  64. }
  65. }
Add Comment
Please, Sign In to add comment