Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <ul>
- <li class="daily">some text </li>
- <li class="daily">some text </li>
- <li>Random li without daily class on it </li>
- <li>Random li without daily class on it </li>
- <li class="daily">some text </li>
- <li> Random li without daily class on it </li>
- <li class="daily">some text </li>
- <li>Random li without daily class on it </li>
- <li class="daily">some text </li>
- <li class="daily">some text </li>
- <li>Random li without daily class on it </li>
- <li class="daily">some text </li>
- </ul>
- <ul (click)="onClick($event)">
- <li>A</li>
- <li>B</li>
- <li>C</li>
- <li>D</li>
- <li>E</li>
- </ul>
- <h2>{{elementClicked}}</h2>
- elementClicked = 'Click any of the list item below'
- onClick(e) {
- this.elementClicked = 'You clicked: ' + e.target.innerHTML;
- }
- <li class="daily" (click)="onClick('some text')">some text </li>
- import { Component } from '@angular/core';
- @Component({
- selector: 'app-component',
- templateUrl: './app-component.html',
- styleUrls: ['./app-component.scss']
- })
- export class AppComponent{
- onClick(param){
- console.log(param);
- //Do something
- }
- }
- values: string[] = ['A', 'B', 'C', 'D'];
- daily(value: string): void {
- // do some action with the passed value
- }
- <ul>
- <li class="daily" *ngFor="let v of values" (click)="daily(v)">{{ v }}</li>
- </ul>
Add Comment
Please, Sign In to add comment