import { Component } from '@angular/core';
import { BlockUI, NgBlockUI } from 'ng-block-ui';
@Component({
selector: 'my-app',
templateUrl: 'app/app.component.html',
styleUrls: ['app/app.component.css']
})
export class AppComponent {
// Wires up BlockUI instance for hero-section directive
@BlockUI('hero-section') blockUI: NgBlockUI;
constructor() {}
toggleBlocking(message?: string) {
this.blockUI.start(message);
setTimeout(() => {
this.blockUI.stop();
}, 2500);
}
}
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { BlockUIModule } from 'ng-block-ui';
@NgModule({
imports: [
BrowserModule,
BlockUIModule.forRoot()
],
declarations: [ AppComponent ],
bootstrap: [ AppComponent ]
})
export class AppModule { }
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app.module';
const platform = platformBrowserDynamic();
platform.bootstrapModule(AppModule);
<!DOCTYPE html>
<html>
<head>
<title>ng-block-ui Example</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="styles.css">
<!-- 1. Load libraries -->
<!-- Polyfill(s) for older browsers -->
<script src="https://unpkg.com/core-js/client/shim.min.js"></script>
<script src="https://unpkg.com/zone.js@0.7.2?main=browser"></script>
<script src="https://unpkg.com/reflect-metadata@0.1.3"></script>
<script src="https://unpkg.com/systemjs@0.19.27/dist/system.src.js"></script>
<!-- 2. Configure SystemJS -->
<script src="systemjs.config.js"></script>
<script>
System.import('app').catch(function(err){ console.error(err); });
</script>
</head>
<!-- 3. Display the application -->
<body>
<my-app></my-app>
</body>
</html>
/**
* PLUNKER VERSION
* (based on systemjs.config.js in angular.io)
* System configuration for Angular 2 samples
* Adjust as necessary for your application needs.
*/
(function (global) {
System.config({
// DEMO ONLY! REAL CODE SHOULD NOT TRANSPILE IN THE BROWSER
transpiler: 'ts',
typescriptOptions: {
tsconfig: true
},
meta: {
'typescript': {
"exports": "ts"
}
},
paths: {
// paths serve as alias
'npm:': 'https://unpkg.com/'
},
// map tells the System loader where to look for things
map: {
// our app is within the app folder
app: 'app',
// angular bundles
'@angular/core': 'npm:@angular/core@5.2.10/bundles/core.umd.js',
'@angular/common': 'npm:@angular/common@5.2.10/bundles/common.umd.js',
'@angular/compiler': 'npm:@angular/compiler@5.2.10/bundles/compiler.umd.js',
'@angular/platform-browser': 'npm:@angular/platform-browser@5.2.10/bundles/platform-browser.umd.js',
'@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic@5.2.10/bundles/platform-browser-dynamic.umd.js',
'@angular/http': 'npm:@angular/http/bundles@5.2.10/http.umd.js',
'@angular/router': 'npm:@angular/router@5.2.10/bundles/router.umd.js',
'@angular/forms': 'npm:@angular/forms@5.2.10/bundles/forms.umd.js',
'@angular/upgrade': 'npm:@angular/upgrade@5.2.10/bundles/upgrade.umd.js',
// other libraries
'rxjs': 'npm:rxjs@5.5.6',
'angular2-in-memory-web-api': 'npm:angular2-in-memory-web-api',
'tslib': 'npm:tslib',
'ts': 'npm:plugin-typescript@4.0.10/lib/plugin.js',
'typescript': 'npm:typescript@2.0.3/lib/typescript.js',
'ng-block-ui': 'npm:ng-block-ui/bundles/umd',
},
// packages tells the System loader how to load when no filename and/or no extension
packages: {
app: {
main: './main.ts',
defaultExtension: 'ts'
},
rxjs: {
defaultExtension: 'js'
},
'angular2-in-memory-web-api': {
main: './index.js',
defaultExtension: 'js'
},
'ng-block-ui': {
main: 'index.js',
defaultExtension: 'js'
},
}
});
})(this);
/*
Copyright 2016 Google Inc. All Rights Reserved.
Use of this source code is governed by an MIT-style license that
can be found in the LICENSE file at http://angular.io/license
*/
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true
}
}
html,
body {
margin: 0;
padding: 0;
font-family: 'Helvetica Neue', 'Helvetica';
}
.hero {
padding: 20px;
min-height: 240px;
background-color: #1976D2;
background: -webkit-linear-gradient(145deg,#9175c5,#42A5F5);
background: linear-gradient(145deg,#9175c5,#42A5F5);
color: #fff;
text-align: center;
}
.hero h1 {
font-size: 3.5em;
margin: 50px 0 0 0;
}
.hero p {
font-size: 1.5em;
margin: 5px 0 15px 0;
}
.block-form {
padding: 70px;
text-align: center;
background: #fff;
}
.control {
display: block;
margin: 5px auto;
padding: 5px;
background: transparent;
font-size: 1.7em;
border: none;
text-align: center;
}
.control__btn {
margin: 15px auto;
padding: 10px 15px;
font-size: 1.3em;
background: #708ada;
color: #fff;
cursor: pointer;
}
.control__input {
color: #708ada;
border-bottom: solid 3px #708ada;
text-align: left;
}
.control__input:focus {
outline: none;
}
.control__input::placeholder {
color: #eae9e9;
}
<!-- Add blockUI directive to element and pass a name -->
<section class="hero" *blockUI="'hero-section'">
<h1>NG Block UI</h1>
<p>Block UI Implementation for Angular 2 & Up</p>
<iframe src="https://ghbtns.com/github-btn.html?user=kuuurt13&repo=ng-block-ui&type=star&size=large" frameborder="0" scrolling="0" width="75px" height="30px"></iframe>
</section>
<section class="block-form">
<input class="control control__input" type="text" placeholder="Custom Message" #blockMessage />
<button class="control control__btn" (click)="toggleBlocking(blockMessage.value)">
Start Blocking
</button>
</section>