Click here to Skip to main content
15,892,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have installed bootstrap in my angular project. In package.json I have "bootstrap":"^3.3.7"

In the component.
import { Component, OnInit, Input } from '@angular/core';

@Component({
  selector: 'zippy',
  templateUrl: './zippy.component.html',
  styleUrls: ['./zippy.component.css']
})
export class ZippyComponent  {
  @Input('title') title: string;
  isExpanded: boolean;

  toggle() { 
    this.isExpanded = !this.isExpanded;
  }

}

In html file
<div class="zippy">
  <div 
    class="zippy-heading"
    [class.expanded]="isExpanded"
    (click)="toggle()"
    >
    {{ title }}
    <span class="glyphicon"
      [ngClass]="{
        'glyphicon-chevron-up': isExpanded,
        'glyphicon-chevron-down': !isExpanded
      }"
    ></span>
  </div>
  <div *ngIf="isExpanded" class="zippy-body">
    <ng-content></ng-content>
  </div>
</div>

But the glyphicon is not showing?

What I have tried:

I tried to add the styles.css into
styleUrls:['./zippy.component.css','./app/styles.css']


Then the error is:
Failed to compile.

./src/app/zippy/zippy.component.ts
Module not found: Error: Can't resolve './app/styles.css' in 'C:\Demo\Angular\tweet\src\app\zippy'
 @ ./src/app/zippy/zippy.component.ts 27:51-78
 @ ./src/app/app.module.ts
 @ ./src/main.ts
 @ multi webpack-dev-server/client?http://localhost:4200 ./src/main.ts
Posted
Updated 31-Jul-21 1:04am
Comments
Kornfeld Eliyahu Peter 31-Jul-17 2:09am    
You should debug your page in-browser, you will find the answer there...
Karthik_Mahalingam 1-Aug-17 4:35am    
check in console window under sources tab

I have to add the line
@import "~bootstrap/dist/css/bootstrap.css";

into style.css file of the project.
 
Share this answer
 
I have added the @import "~bootstrap/dist/css/bootstrap.css"; as well
but it still does not show.
 
Share this answer
 
bootstrap": "4.1.3"

If I am not wrong
glyphicon is not supported after bootstrap 4.
bootstrap uses other packages to display icon. you can find the links in its website
if you wanna to use glyphicon. install bootstrap 3.
or add inside your index.html within
 
Share this answer
 
Comments
Richard Deeming 30-Oct-19 15:23pm    
The OP clearly stated they were using Bootstrap 3.3.7, and made absolutely no mention of 4.1.3 anywhere.
barwalgayatri 31-Jul-21 7:04am    
Solution 4 worked for me too Thanks. But the doubt is How to add Star glyphicon in upper version?
Solution 4 is right!
bootstrap": "4.1.3" doesn't support glyphicon.
pls follow above commands to uninstall current version of bootstrap:

>> npm uninstall bootstrap

>> npm install bootstrap@3.3.7

and it worked for me!

Thanks for solution 4!!
 
Share this answer
 
Comments
CHill60 11-May-20 4:06am    
If you want to comment on a solution then use the "Have a Question or Comment?" link next to it. And it doesn't matter that 4.1.3 doesn't support glyphicon when the OP is using 3.3.7!
barwalgayatri 31-Jul-21 7:04am    
Solution 4 worked for me too Thanks. But the doubt is How to add Star glyphicon in upper version?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900