Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <template #content let-c="close" let-d="dismiss">
- <div class="modal-body">
- <p>Modal body</p>
- </div>
- </template>
- import { Component } from '@angular/core';
- import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
- @Component({
- selector: 'my-hello-home-modal',
- templateUrl: './hellohome.modal.html'
- })
- export class HelloHomeModalComponent {
- closeResult: string;
- constructor(private modal: NgbModal) {}
- open(content) {
- this.modal.open(content).result.then((result) => {
- this.closeResult = `Closed with: ${result}`;
- }, (reason) => {
- console.log(reason);
- });
- }
- }
- import { Component, OnInit } from '@angular/core';
- @Component({
- selector: 'my-home',
- templateUrl: './home.component.html'
- })
- export class HomeComponent implements OnInit {
- constructor() {
- }
- ngOnInit() {
- console.log('Hello Home');
- /** want call modal popin here from the init component method in order to test the modal. **/
- }
- }
- @Component({
- selector: 'my-home',
- templateUrl: 'src/modal-basic.html'
- })
- export class HomeComponent implements OnInit {
- constructor(private modalService: NgbModal) {}
- ngOnInit(content) {
- this.modalService.open('Hi tehre!');
- }
- }
- import { Component, OnInit } from '@angular/core';
- import { HelloHomeModalComponent } from "hello-home-modal.component";
- @Component({
- selector: 'my-home',
- templateUrl: './home.component.html'
- })
- export class HomeComponent implements OnInit {
- constructor(private modal: HelloHomeModalComponent) {}
- ngOnInit() {
- this.modal.open();
- }
- }
- import { Component, OnInit } from '@angular/core';
- import {NgbActiveModal} from '@ng-bootstrap/ng-bootstrap';
- @Component({
- selector: 'sm-create-asset-modal',
- templateUrl: './create-asset-modal.component.html',
- styleUrls: ['./create-asset-modal.component.css']
- })
- export class CreateAssetModalComponent implements OnInit {
- constructor(public activeModal: NgbActiveModal) { }
- ngOnInit() {
- }
- }
- <div class="modal-header">
- <h4 class="modal-title">Create New </h4>
- <button type="button" class="close" aria-label="Close" (click)="activeModal.dismiss('Cross click')">
- <span aria-hidden="true">×</span>
- </button>
- </div>
- <div class="modal-body">
- <p>One fine body…</p>
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-success" (click)="activeModal.close('Close click')">Create</button>
- </div>
- export class MyComponent {
- constructor(private modal: NgbModal) {}
- onClick() {
- this.modal.open(CreateAssetModalComponent);
- }
- }
- @NgModule({
- imports: [...],
- declarations: [CreateAssetModalComponent],
- entryComponents: [CreateAssetModalComponent]
- })
Add Comment
Please, Sign In to add comment