如何将字体超赞库提取到单独的库中?

时间:2018-11-02 17:08:55

标签: angular typescript angular6 font-awesome

我使用https://www.npmjs.com/package/angular-font-awesome取得了巨大的成功,但是随着我添加越来越多的图标,我的app.module.ts的大小也随之增加:

enter image description here

是否可以将其提取到单独的文件中以处理我的图标库,然后将该文件导入app.module.ts中,以便我所有的组件都可以访问它?

1 个答案:

答案 0 :(得分:-1)

只需创建一个将其导出的模块:

#include <iostream>
#include <map>

using namespace std;

std::map<string, bool> myData;

int main()
{
    // THIS IS SAMPLE INSERT. INTRODUCE LOOP FOR INSERT.
    /*00010 0
    00011 1
    00100 0
    00101 1
    00110 1*/
    myData.insert(std::pair<string, bool>("00010", 0));
    myData.insert(std::pair<string, bool>("00011", 1));
    myData.insert(std::pair<string, bool>("00100", 0));
    myData.insert(std::pair<string, bool>("00101", 1));
    myData.insert(std::pair<string, bool>("00110", 1));

    // Display contents
    std::cout << "My Data:\n";
    std::map<string, bool>::iterator it;

    for (it=myData.begin(); it!=myData.end(); ++it)
        std::cout << it->first << " => " << it->second << '\n';

    return 0;
} 

然后在您的app.module中:

import { NgModule } from '@angular/core';
....

/**
 * Implementation for the icon logic.
 */
@NgModule({
  imports: [
    faVideo,
    faList,
    ....
  ],
  exports: [
    faVideo,
    faList,
    ....
  ],
})
export class IconModule {}

并导入

import { IconModule } from './modules/icon'`

但是,这就是我只使用CSS的原因之一