问题
i wanna use a librairy which i got from a bower repo .
Since it's not available in NPM , i wanna know how may it get it work and configure it within my app , my structure looks like this :
I have tried to deal it like any other library by typing
import * as DX from 'bower_components/xtrareportsjs';
and i have tried to add it as a script in the index.html OR the angular-cli.json scripts' part:
<script src="bower_components/xtrareportsjs/report-designer.js"></script>
but that didn't recognoze it in all of those case.
NB : i wanna reutilize my file (like jQuery) not just excecute it
I found old explications , about importation under system.JS but as you can see it's not my case.
Suggestions ??
回答1:
I managed to use jquery
just go to your angular-cli.json file
then import path of your desired library inside the scripts
Please check the photo below:
And then use it on your component like this
declare var $: any;
@Component({
selector: 'app-navigation',
templateUrl: './navigation.component.html',
styleUrls: ['./navigation.component.css']
})
export class NavigationComponent implements OnInit {
constructor(){}
ngOnInit(){
console.log($('#myElement'));
}
}
来源:https://stackoverflow.com/questions/45440350/angular-how-to-load-external-library-from-bower-not-available-in-npm