Use jQuery script with Angular 6 CLI project

后端 未结 3 1653
不思量自难忘°
不思量自难忘° 2021-01-07 05:45

I\'m developing an application using angular 6. My application use Minton Theme . I included all theme scripts in the index.html file of my angular project. Bu

3条回答
  •  误落风尘
    2021-01-07 06:11

    Here is an example I hope helps. It is not exactly what you need but I'm hopping you can find parts that will save your time:

        import { Component, OnInit, AfterViewInit } from '@angular/core';
        import { Router } from '@angular/router';
        import * as $ from 'jquery'
    
        import { Globals } from '../helpers/globals';
    
        @Component({
            selector: 'app-root',
            templateUrl: './app.component.html',
            styleUrls: ['./app.component.css']
        })
    
        export class AppComponent implements OnInit, AfterViewInit {
            title = 'dashboard-app';
            authentication = false;
    
            constructor(private globals: Globals) {
    
            }
    
            ngOnInit() {
    
                // this.helpers.logout();
                // this.router.navigate(['/login']);
            }
    
            ngAfterViewInit() {
                // loading templates js after dom render
                $.getScript("../plugins/custombox/dist/custombox.min.js", function () {
                });
                $.getScript("../plugins/custombox/dist/legacy.min.js", function () {
                });
    
                $.getScript("/assets/js/jquery.core.js", function () {
                });
                $.getScript("/assets/js/jquery.app.js", function () {
                });
            }
        }
    

提交回复
热议问题