| Total Complexity | 3 |
| Complexity/F | 1 |
| Lines of Code | 42 |
| Function Count | 3 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import { Component, OnInit } from "@angular/core"; |
||
| 2 | import { Subscription } from "rxjs"; |
||
| 3 | import { ProductService } from "src/app/services/products.service"; |
||
| 4 | import { Response } from "src/app/models/response"; |
||
| 5 | import { TranslateService } from '@ngx-translate/core'; |
||
| 6 | |||
| 7 | @Component({ |
||
| 8 | selector: "app-home", |
||
| 9 | templateUrl: "./home.component.html", |
||
| 10 | styleUrls: ["./home.component.scss"] |
||
| 11 | }) |
||
| 12 | export class HomeComponent implements OnInit { |
||
| 13 | |||
| 14 | products; |
||
| 15 | productSub; |
||
| 16 | |||
| 17 | constructor(private ProductService: ProductService, public translate: TranslateService) { |
||
| 18 | translate.addLangs(['fr', 'en']); |
||
| 19 | translate.setDefaultLang('fr'); |
||
| 20 | } |
||
| 21 | |||
| 22 | ngOnInit(): void { |
||
| 23 | this.productSub = this.ProductService.getProducts().subscribe ( |
||
| 24 | (response: Response) => { |
||
| 25 | this.products = response.result; |
||
| 26 | }, |
||
| 27 | (error) => { |
||
| 28 | // TODO delete console.log |
||
| 29 | console.log(error); |
||
| 30 | } |
||
| 31 | ); |
||
| 32 | } |
||
| 33 | |||
| 34 | useLanguage(language: string): void { |
||
| 35 | this.translate.use(language); |
||
| 36 | } |
||
| 37 | |||
| 38 | switchLang(lang: string) { |
||
| 39 | this.translate.use(lang); |
||
| 40 | } |
||
| 41 | } |
||
| 42 |