Skip to content

Instantly share code, notes, and snippets.

@zkkmin
Created June 30, 2018 23:13
Show Gist options
  • Save zkkmin/269fcbd8f6a7163d2c94eac5425ae242 to your computer and use it in GitHub Desktop.
Save zkkmin/269fcbd8f6a7163d2c94eac5425ae242 to your computer and use it in GitHub Desktop.
import { Component, OnInit } from '@angular/core';
import { QuoteService } from '../quote.service';
@Component({
selector: 'app-random-quote',
templateUrl: './random-quote.component.html',
styleUrls: ['./random-quote.component.css']
})
export class RandomQuoteComponent implements OnInit {
constructor(private quoteService: QuoteService) { }
getQuote(): void {
this.quoteService.getQuote()
.subscribe(quote => {
this.quote = '"' + quote['quote'] + '"';
this.author = '~' + quote['author']
});
}
quote: string;
author: string;
ngOnInit() {
this.getQuote();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment