michaelbazos/angular-feather

I can't get the icons by its name -> Error not found : iconName

Closed this issue · 2 comments

I can't get the icons by its name.
Looking the error, I saw that the array is being build with index numbers instead of their alias name.
I'm using angular 8.0.3, I don't think this could be the problem.

image

icons.module.ts :

`
import { NgModule } from '@angular/core';
import { FeatherModule } from 'angular-feather';
import {
Slash,
Info,
Check,
Home,
Github,
Archive,
Heart
} from 'angular-feather/icons';

const icons = [Slash, Info, Check, Home, Github, Archive, Heart];

@NgModule({
imports: [FeatherModule.pick(icons)],
exports: [FeatherModule]
})
export class IconsModule {}
`

<i-feather name="3" ></i-feather> Working
<i-feather name="home" ></i-feather> Not Working

@fflores-origin

It's a bit subtle, but that is because the variable you pass to FeatherModule.pick(...) should be an object and not an array:

const icons = { Slash, Info, Check, Home, Github, Archive, Heart };

which in ES6 is a shorthand notation for:

const icons = {
  'Slash': Slash, 
  'Info': Info,
  'Check': Check, 
  'Home': Home
...
};

Ohhh thanks dude!! That solved my problem. I didnt' realize that I used an array!!