country-list-with-dial-code-and-flag icon indicating copy to clipboard operation
country-list-with-dial-code-and-flag copied to clipboard

Emoji displaying

Open khitrukhina opened this issue 3 years ago • 12 comments

I see, that you've already answered on issues like that, but it IS here. They are partially displayed. And when they are not, the text is displayed. Like on the attached screenshot. I am using Angular. imgpsh_fullsize_anim

khitrukhina avatar Oct 13 '22 16:10 khitrukhina

Which plugin or library did you used for select box? May be the plugin issue?

necessarylion avatar Oct 13 '22 16:10 necessarylion

It's angular material )

khitrukhina avatar Oct 13 '22 16:10 khitrukhina

Could you show your code here? It work fine for me.

 <mat-form-field appearance="fill">
    <mat-label>Country Codes</mat-label>
    <mat-select>
      <mat-option *ngFor="let list of countryLists" [value]="list.dial_code">
        {{list.flag}} {{list.dial_code}}
      </mat-option>
    </mat-select>
  </mat-form-field>
import { Component } from '@angular/core';
//@ts-ignore
import CountryList from 'country-list-with-dial-code-and-flag'

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'my-app-angular';
  countryLists = CountryList.getList();
}
Screen Shot 2022-10-14 at 12 01 30 AM

necessarylion avatar Oct 13 '22 17:10 necessarylion

Maybe you have met some unexpected behaviour with emojis?)

khitrukhina avatar Oct 13 '22 17:10 khitrukhina

It's Windows problem. Everyone who has linix/mac - sees emoji. Windows - no.

https://answers.microsoft.com/en-us/windows/forum/all/flag-emoji/85b163bc-786a-4918-9042-763ccf4b6c05?page=4

khitrukhina avatar Oct 17 '22 11:10 khitrukhina

There are svg and png format available here in this repo. May be you can download and use in your code.

necessarylion avatar Oct 17 '22 23:10 necessarylion

Have used this polyfill https://www.npmjs.com/package/country-flag-emoji-polyfill

khitrukhina avatar Oct 18 '22 09:10 khitrukhina

Removed pollyfill as its working only with cdn. Resolved like this: angular.json { "glob": "**/*", "input": "./node_modules/country-list-with-dial-code-and-flag/assets/png", "output": "assets/flags" }

component: ` readonly countriesList = countryList.getList().map(country => { const pathName = country.code.toLowerCase(); if (pathName === 'an') { return country; }

country.path = `./assets/flags/${pathName}.png`;
return country;

});`

khitrukhina avatar Oct 28 '22 13:10 khitrukhina

New version 4.0 now support svg. https://www.npmjs.com/package/country-list-with-dial-code-and-flag/v/4.0.0

import CountryFlagSvg from 'country-list-with-dial-code-and-flag/dist/flag-svg'

const myanmar = CountryList.findOneByCountryCode('mm')
if(myanmar) {
    const flagSvg = CountryFlagSvg[myanmar.code] // .js
    const flagSvg = CountryFlagSvg[myanmar.code as never] // .ts
    console.log(flagSvg) // it return svg string
}

necessarylion avatar Apr 01 '23 13:04 necessarylion

I tried to use the svg string in angular project, but it's not shown.

ngdevc avatar Mar 16 '25 16:03 ngdevc

I haven't try svg on angular project yet. Not sure if we can use like this?

const svgDataUrl = `data:image/svg+xml;utf8,${encodeURIComponent(flagSvg)}`;

And then use in image src.

necessarylion avatar Mar 17 '25 05:03 necessarylion