angular 4にsvgを導入
4681 ワード
アリコン
直接assetsフォルダに入れてhtmlを導入すればいい
注:ルートの場所はindex.htmlファイルの場所です.
動的変更svg
ngStyleコマンドを使用できます
または
angularではjqueryの使用をできるだけ避ける
font-awesomeの導入
There are 3 parts to using Font-Awesome in Angular Projects
Installation Styling (CSS/SCSS) Usage in Angular Installation
Install from NPM and save to your package.json
Styling If using CSS
Insert into your style.css
Styling If using SCSS
Insert into your style.scss
Usage with plain Angular 2.4+ 4+
Materialと併用
In your app.module.ts modify the constructor to use the MdIconRegistry
and add MdIconModule to your @NgModule imports
Now in any template file you can now do
materialを単独で使用
index.html
直接assetsフォルダに入れてhtmlを導入すればいい
<div>
<img src="yourIcon.svg">
div>
注:ルートの場所はindex.htmlファイルの場所です.
動的変更svg
ngStyleコマンドを使用できます
"{stroke:stroke, fill: fill}"
id="XMLID_1_"
class="st0" cx="91.2" cy="87.2" r="10"
(mouseover)="func1()"/>
または
.stroke]="stroke"
[style.fill]="fill"
id="XMLID_1_"
class="st0" cx="91.2" cy="87.2" r="10"
(mouseover)="func1()"/>
angularではjqueryの使用をできるだけ避ける
font-awesomeの導入
There are 3 parts to using Font-Awesome in Angular Projects
Installation Styling (CSS/SCSS) Usage in Angular Installation
Install from NPM and save to your package.json
npm install --save font-awesome
Styling If using CSS
Insert into your style.css
@import '~font-awesome/css/font-awesome.css';
Styling If using SCSS
Insert into your style.scss
$fa-font-path: "../node_modules/font-awesome/fonts";
@import '~font-awesome/scss/font-awesome.scss';
Usage with plain Angular 2.4+ 4+
<i class="fa fa-area-chart">i>
Materialと併用
In your app.module.ts modify the constructor to use the MdIconRegistry
export class AppModule {
constructor(mdIconRegistry: MdIconRegistry) {
mdIconRegistry.registerFontClassAlias('fontawesome', 'fa');
}
}
and add MdIconModule to your @NgModule imports
@NgModule({
imports: [
MdIconModule,
....
],
declarations: ....
}
Now in any template file you can now do
<md-icon fontSet="fontawesome" fontIcon="fa-area-chart">md-icon>
materialを単独で使用
index.html
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">