loading.service.ts 990 Bytes
import { Injectable } from '@angular/core';
declare var $: any;
@Injectable()
export class LoadingService {
    constructor() { }
    ShowLoading(loadingId) {
        let el = document.getElementById(loadingId);
        let mask = document.getElementById("loading-mask");
        if (mask != null && mask != undefined) {
            $(mask).show();
            mask.className = 'loading-mask';
        }
        if (el != undefined && el != null) {
            $(el).show();
            el.className = 'loading-app';
        }
    }
    HideLoading(loadingId) {
        let el = document.getElementById(loadingId);
        let mask = document.getElementById("loading-mask");
        if (mask != null && mask != undefined) {
            $(mask).fadeOut(1000);
            setTimeout(() => mask.className = '', 1000);
        }
        if (el != undefined && el != null) {           
            $(el).fadeOut(300);
            setTimeout(() => el.className = '', 300);
        }
    }
}