npm i ngx-popup
app.module.ts
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { FormsModule } from '@angular/forms'; import { AppComponent } from './app.component'; import { HelloComponent } from './hello.component'; import { ModalComponent } from './modal/modal.component'; import { InfiniteScrollModule } from 'ngx-infinite-scroll'; declare const chance; @NgModule({ imports: [ BrowserModule, FormsModule, InfiniteScrollModule ], declarations: [ AppComponent, HelloComponent, ModalComponent ], bootstrap: [ AppComponent ] }) export class AppModule { } |
app.component.ts
1 2 3 4 5 6 7 8 9 10 |
import { Component, VERSION } from '@angular/core'; @Component({ selector: 'my-app', templateUrl: './app.component.html', styleUrls: [ './app.component.css' ] }) export class AppComponent { name = 'Angular ' + VERSION.major; } |
app.component.html
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
import { Component, OnInit } from '@angular/core' @Component({ selector: 'base-demo', template: ` <ngx-popup [(ngModel)]="visible"> <div style="background: #fff; padding: 50px;">hello world</div> </ngx-popup> <button (click)="show()">show</button> ` }) export class BaseComponent implements OnInit { constructor() {} visible = false ngOnInit() {} show() { this.visible = true } } |
FULL SOURCE CODE