File

src/components/tick-tock/tick-tock.component.ts

Implements

OnInit

Metadata

selector tick-tock
styleUrls tick-tock.component.scss
templateUrl ./tick-tock.component.html

Index

Properties

Constructor

constructor(tickTockService: TickTockService)

Component constructor with injected dependencies.

Parameters :
Name Type Optional Description
tickTockService TickTockService

Properties

Public currentTime
currentTime: string
Type : string
import { Component, OnInit } from '@angular/core';

import { TickTockService } from '../../services';

@Component({
  selector: 'tick-tock',
  styleUrls: ['./tick-tock.component.scss'],
  templateUrl: './tick-tock.component.html',
})
export class TickTockComponent implements OnInit {
  // Current time string.
  public currentTime: string;

  /**
   * Component constructor with injected dependencies.
   * @param tickTockService
   */
  public constructor(
    private tickTockService: TickTockService
  ) {}

  /**
   * Implements onInit event handler.
   */
  public ngOnInit(): void {
    this.tickTockService.getTick().subscribe(
      (timeString) => this.currentTime = timeString
    );
  }
}
<div class="tick-tock-time">
  {{ currentTime }}
</div>
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""