Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- varags
- Android
- Web Service
- Bootstrap
- Maven
- 자바
- 이클립스
- html
- WebView
- 컬럼명
- javascript
- SpringSource Tool Suite
- TextBox
- asp.net
- MSsql
- 웹뷰
- jsp
- decompiler
- Apache Lucene
- C#
- MS-SQL
- Java
- MANTIS
- 웹 서비스
- 자바스크립트
- 안드로이드
- STS
- scrollView
- Redirect
- Eclipse
Archives
- Today
- Total
bboks.net™
Ionic에서 fontawsome 사용하기 본문
1. 프로젝트 생성
ionic start fontawsome-tutorial blank --type=angular
2. fontawsome 라이브러리 설치
npm i @fortawesome/angular-fontawesome
npm i @fortawesome/fontawesome-svg-core
npm i @fortawesome/free-solid-svg-icons
npm i @fortawesome/free-regular-svg-icons
npm i @fortawesome/free-brands-svg-icons
3. app.module.ts 수정
library import
import { FontAwesomeModule, FaIconLibrary } from '@fortawesome/angular-fontawesome';
import { fas } from '@fortawesome/free-solid-svg-icons';
import { far } from '@fortawesome/free-regular-svg-icons';
import { fab } from '@fortawesome/free-brands-svg-icons';
constructor 추가
constructor(library: FaIconLibrary) {
library.addIconPacks(fas, fab, far);
}
NgModule import 추가
imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule, FontAwesomeModule],
전체 app.module.ts 소스
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouteReuseStrategy } from '@angular/router';
import { IonicModule, IonicRouteStrategy } from '@ionic/angular';
import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';
import { FontAwesomeModule, FaIconLibrary } from '@fortawesome/angular-fontawesome';
import { fas } from '@fortawesome/free-solid-svg-icons';
import { far } from '@fortawesome/free-regular-svg-icons';
import { fab } from '@fortawesome/free-brands-svg-icons';
@NgModule({
declarations: [AppComponent],
entryComponents: [],
imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule, FontAwesomeModule],
providers: [{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy }],
bootstrap: [AppComponent],
})
export class AppModule {
constructor(library: FaIconLibrary) {
library.addIconPacks(fas, fab, far);
}
}
4. home.module.ts 수정
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { IonicModule } from '@ionic/angular';
import { FormsModule } from '@angular/forms';
import { HomePage } from './home.page';
import { HomePageRoutingModule } from './home-routing.module';
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
HomePageRoutingModule,
FontAwesomeModule
],
declarations: [HomePage]
})
export class HomePageModule {}
5. home.html 수정
<ion-header [translucent]="true">
<ion-toolbar>
<ion-title>
Blank
</ion-title>
</ion-toolbar>
</ion-header>
<ion-content [fullscreen]="true">
<fa-icon icon="home"></fa-icon>
</ion-content>
6. ionic serve를 이용해 확인
[참조]
Add Font Awesome to your Ionic 5 App — The Step-by-Step Guide