Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap Glyphicons not displaying in angular2

I am trying to use bootstrap glyphicons in my angular2 app. I have installed bootstrap using the command npm install bootstrap --save My code snippet is

 <button *ngIf="pos.name == uname" type="button" class="btn btn-default       btn-sm delete" (click)="DeleteBulletin();">    <span class="glyphicon glyphicon-trash glyph"></span>  Delete  </button> 

I have included bootstrap in my styleUrls- styleUrls: ['node_modules/bootstrap/dist/css/bootstrap.min.css', 'app/home.component.css']

The glyphicon appears as shown- enter image description here

like image 935
Sahana ys Avatar asked Jun 20 '16 06:06

Sahana ys


2 Answers

Boostrap 4 does not support Glyphicons anymore, you can use Font Awesome instead:

npm install --save fortawesome/fontawesome-free 

OR install the official Angular Fontawesome Package: https://github.com/FortAwesome/angular-fontawesome

and add the css File to your .angular-cli.json

"apps": [           {              ....              "styles": [                 "styles.css",                 "../node_modules/bootstrap/dist/css/bootstrap.css",                 "../node_modules/font-awesome/css/font-awesome.css"              ],              ...          }        ]  ], 

Replace CSS class with the Font Awesome classes:

<i class="navbar-toggler-icon fa fa-bars"> </i> 

recompile app: ng serve

like image 86
Sebastian Viereck Avatar answered Sep 20 '22 14:09

Sebastian Viereck


You have to import

<link data-require="[email protected]" data-semver="3.3.6" rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.css" />

to your index.html

like image 29
supersonic Avatar answered Sep 17 '22 14:09

supersonic