Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Angular
- import { Component, OnInit } from '@angular/core';
- // Service
- import { DynamicScriptLoaderService } from '../../shared/services/dynamic-script-loader.service';
- @Component({
- selector: 'app-dashboard',
- templateUrl: './dashboard.component.html'
- })
- export class DashboardComponent implements OnInit {
- constructor(private dynamicScriptLoader: DynamicScriptLoaderService) {}
- ngOnInit() {
- // Just call your load scripts function with scripts you want to load
- this.loadStripeScripts();
- }
- private loadChartScripts() {
- // You can load multiple scripts by just providing the key as argument into load method of the service
- this.dynamicScriptLoader.load('chartjs','random-num').then(data => {
- // Script Loaded Successfully
- }).catch(error => console.log(error));
- }
- }
Add Comment
Please, Sign In to add comment