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 | 29 | 30 |
Tags
- MSsql
- javascript
- 웹뷰
- STS
- decompiler
- 컬럼명
- asp.net
- Bootstrap
- Web Service
- 안드로이드
- 웹 서비스
- MS-SQL
- varags
- Apache Lucene
- 이클립스
- Redirect
- 자바
- WebView
- Android
- jsp
- 자바스크립트
- MANTIS
- Maven
- scrollView
- TextBox
- C#
- SpringSource Tool Suite
- Java
- Eclipse
- html
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