title: Angular: How to make a time signal in
body: <p>I need to make a traffic light that from 0 to 10 minutes is green from 10 to 20 yellow and from 20 to 30 red, time is by service</p>
  
  <p>So far this is my code</p>
  
  <p>This is the component</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>import {
    Component,
    OnInit,
    Input
  } from '@angular/core';
  import {
    TiempoService
  } from "app/servicios/tiempo.service"
  
  @Component({
    selector: 'app-menu',
    templateUrl: './menu.component.html',
    styleUrls: ['./menu.component.css']
  })
  export class MenuComponent implements OnInit {
  
    @Input() tiemposervice: TiempoService;
    constructor() {}
  
    ngOnInit() {
  
  
    }
  
  
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>This is the HTML</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="row"&gt;
    &lt;div class="small-12 medium-6 columns"&gt;
      &lt;span&gt;Tiempo transcurrido&lt;/span&gt;
      &lt;h5&gt;{{tiempoTranscurrido | date:'mm:ss'}}&lt;/h5&gt;
    &lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>This is the service</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>import {
    Injectable
  } from '@angular/core';
  import Rx from 'Rx';
  
  @Injectable()
  export class TiempoService {
  
    tiempoTranscurrido: number;
  
  
    constructor() {}
  
    ngOnInit() {
  
    }
    tiempoTotal() {
      Rx.Observable.interval(1000).subscribe(segundos =&gt; {
        this.tiempoTranscurrido = segundos * 1000;
      })
    }
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>I would greatly appreciate your help.</p>