I'm trying to add ionicons to my Angular 4 app. Here are the steps taken:
Am I missing somrthing?
To embed an Ionicon in HTML all you have to do is copy the scripts from the installation section of the Ionicons and paste them in your HTML document. Afterward, select the Ionicon of your choice, copy the component code and paste it into your HTML document.
To use the Ionicons in React Native you have to import react-native-ionicons dependency which will provide an Icon component. You can use this Icon component to create an Icon. Prop “name” will render the same icon in Android and IOS.
For adding Ionic to an already existing Angular project, use the Angular CLI's ng add feature. This will add the necessary imports to the @ionic/angular package as well as add the styles needed.
The way to get ionicons in angular 6.3.x and npm 6.1.x working ...
npm install ionicons@latest --save
"ionicons": "^4.2.4"
will automatically appear in your project dependencies in your package.json
"node_modules/ionicons/dist/scss/ionicons.scss"
under "styles": []
section inside your angular.json
<span class="ion ion-md-attach"></span>
in your app.component.html
or index.html
or any markup file of your choiceThe following command will allow you to use the ion-*
classes and the <ion-icon name="..."></ion-icons>
web component that's available with Ionicons 4.x:
ng add @ionic/angular
This is a built-in Angular schematic that installs the Ionic library and it's components, which includes icons. Once this complete you can use Ionicons in your project like this:
<ion-icon name="logo-facebook"></ion-icon>
The name
property corresponds to the value provided in the Web Component Code provided for a specific icon at ionicons.com.
Probably you got your answer already but here how i added in my project:
Add ionicons to your project
npm install ionicons@'2.0.1' --save
or add following in package.json
"dependencies": {
"ionicons": "2.0.1",
}
Then add the css or sass file in the angular-cli.json to be loaded into your application.
"styles": [
"../node_modules/ionicons/scss/ionicons.scss"
]
Note: The path might change depending on the version your are going to install. For the version mention above this is the path.
Now you should be good to go.
class="ion-trash-a"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With