Skip to content

Instantly share code, notes, and snippets.

@neilsoult
neilsoult / LazyLoad.js
Created October 31, 2013 19:40
LazyLoad directive for loading external javascript for AngularJs. In this example, I use google maps' API as the external library being loaded
angular.module('testApp', []).
directive('lazyLoad', ['$window', '$q', function ($window, $q) {
function load_script() {
var s = document.createElement('script'); // use global document since Angular's $document is weak
s.src = 'https://maps.googleapis.com/maps/api/js?sensor=false&callback=initialize';
document.body.appendChild(s);
}
function lazyLoadApi(key) {
var deferred = $q.defer();
$window.initialize = function () {

Keybase proof

I hereby claim:

  • I am neilsoult on github.
  • I am nsoult (https://keybase.io/nsoult) on keybase.
  • I have a public key ASBYlAZ8utb-NstsNlguustGuhtUsMT20aCNqlOiKtb1wwo

To claim this, I am signing this object:

@neilsoult
neilsoult / custom-webpack.config.js
Created June 18, 2020 02:31
Custom webpack config to use with @angular-builders/custom-webpack
const ngTools = require("@ngtools/webpack");
const path = require('path');
module.exports = (config) => {
// add pug loader into webpack module rules
config.module.rules = [
{
test: /.(pug|jade)$/,
exclude: /.(include|partial).(pug|jade)$/,
import { Component, createNgModuleRef, Injector, Input, OnChanges, ViewChild } from '@angular/core';
import { loadRemoteModule } from '@nrwl/angular/mfe';
import { PluginDirective } from './plugin-directive';
// plugin directive:
// import { Directive, ViewContainerRef } from '@angular/core';
// @Directive({ selector: '[crxPlugin]' })
// export class PluginDirective {
// constructor (public viewContainerRef: ViewContainerRef) { }