My angular component looks like:
@Component({
selector: 'home',
templateUrl: './home.component.html',
styleUrls: ['https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.1/css/bootstrap.min.css',
'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css']
})
And at the step of compilation via angular-cli I have errors:
Module not found: Error: Can't resolve './https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.1/css/bootstrap.min.css'
Module not found: Error: Can't resolve './https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css'
How can I resolve my issue?
3
Answers
Only import your component .scss .css file like that
If you creat a files for each import then import like that.
It worked in this link https://stackblitz.com/edit/angular-bs4-from-assets
The best way is to install this js and CSS which is the proper way
Use this commands for the bootstrap and fontawesome installation
Then add there links in styles and scripts in angular.json file
When building single page application the goal is to keep its size as small as possible, and importing entire library into the component is not the way to do it… In order to use Font Awesome you need to use following Angular FontAwesome library It supports imports and tree-shaking.
In order to use Bootstrap 4 you don’t need min version – you need SASS files, thus you need to:
1. Install it as a package
2. Import bootstrap into global styles, I use variables to import:
Import in global styles.scss