Guest User

Untitled

a guest
Jul 17th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. // Angular
  2. import { Component, OnInit } from '@angular/core';
  3.  
  4. // Service
  5. import { DynamicScriptLoaderService } from '../../shared/services/dynamic-script-loader.service';
  6.  
  7. @Component({
  8. selector: 'app-dashboard',
  9. templateUrl: './dashboard.component.html'
  10. })
  11. export class DashboardComponent implements OnInit {
  12.  
  13.  
  14. constructor(private dynamicScriptLoader: DynamicScriptLoaderService) {}
  15.  
  16. ngOnInit() {
  17. // Just call your load scripts function with scripts you want to load
  18. this.loadStripeScripts();
  19. }
  20.  
  21. private loadChartScripts() {
  22. // You can load multiple scripts by just providing the key as argument into load method of the service
  23. this.dynamicScriptLoader.load('chartjs','random-num').then(data => {
  24. // Script Loaded Successfully
  25. }).catch(error => console.log(error));
  26. }
  27.  
  28. }
Add Comment
Please, Sign In to add comment