File

apps/live-weather/src/app/shared/country-flag/country-flag.component.ts

Metadata

selector weather-base-country-flag
styleUrls ./country-flag.component.scss
templateUrl ./country-flag.component.html

Index

Properties
Inputs
Accessors

Inputs

country
Type : string

set country and create url to get flag

Properties

Private _country
Type : string
Default value : ''
Public flagUrl
Type : string
Default value : ''

Accessors

country
getcountry()

Get Country

Returns : string
setcountry(value: string)

set country and create url to get flag

Parameters :
Name Type Optional
value string No
Returns : void
import { Component, Input } from '@angular/core';

@Component({
  selector: 'weather-base-country-flag',
  templateUrl: './country-flag.component.html',
  styleUrls: ['./country-flag.component.scss'],
})
/**
 * Provide icon for any country flag
 */
export class CountryFlagComponent {
  // eslint-disable-next-line @typescript-eslint/naming-convention
  private _country = '';

  public flagUrl = '';

  /**
   * Get Country
   *
   * @returns name of the country
   */
  get country(): string {
    return this._country;
  }

  /**
   * set country and create url to get flag
   */
  @Input()
  set country(value: string) {
    this.flagUrl = `https://www.countryflags.io/${value.toLowerCase()}/shiny/24.png`;
    this._country = value;
  }
}
<img [src]="flagUrl" class="country-flag" />

./country-flag.component.scss

.country-flag {
  width: 24px;
  height: 24px;
}
Legend
Html element
Component
Html element with directive

result-matching ""

    No results matching ""