Guest User

Untitled

a guest
Oct 23rd, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. <ul>
  2. <li class="daily">some text </li>
  3. <li class="daily">some text </li>
  4. <li>Random li without daily class on it </li>
  5. <li>Random li without daily class on it </li>
  6. <li class="daily">some text </li>
  7. <li> Random li without daily class on it </li>
  8. <li class="daily">some text </li>
  9. <li>Random li without daily class on it </li>
  10. <li class="daily">some text </li>
  11. <li class="daily">some text </li>
  12. <li>Random li without daily class on it </li>
  13. <li class="daily">some text </li>
  14. </ul>
  15.  
  16. <ul (click)="onClick($event)">
  17. <li>A</li>
  18. <li>B</li>
  19. <li>C</li>
  20. <li>D</li>
  21. <li>E</li>
  22. </ul>
  23. <h2>{{elementClicked}}</h2>
  24.  
  25. elementClicked = 'Click any of the list item below'
  26.  
  27. onClick(e) {
  28. this.elementClicked = 'You clicked: ' + e.target.innerHTML;
  29. }
  30.  
  31. <li class="daily" (click)="onClick('some text')">some text </li>
  32.  
  33. import { Component } from '@angular/core';
  34.  
  35. @Component({
  36. selector: 'app-component',
  37. templateUrl: './app-component.html',
  38. styleUrls: ['./app-component.scss']
  39. })
  40.  
  41. export class AppComponent{
  42.  
  43.  
  44. onClick(param){
  45. console.log(param);
  46. //Do something
  47. }
  48.  
  49.  
  50. }
  51.  
  52. values: string[] = ['A', 'B', 'C', 'D'];
  53.  
  54. daily(value: string): void {
  55. // do some action with the passed value
  56. }
  57.  
  58. <ul>
  59. <li class="daily" *ngFor="let v of values" (click)="daily(v)">{{ v }}</li>
  60. </ul>
Add Comment
Please, Sign In to add comment