Skip to content

Commit

Permalink
fix(bootstrap): removed the dependency of the FormModule in the promp…
Browse files Browse the repository at this point in the history
…t modal
  • Loading branch information
CaselIT committed Sep 1, 2016
1 parent 329f987 commit 07fcce8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';

import { ModalModule, Modal as BaseModal } from '../../../../components/angular2-modal';

Expand All @@ -21,7 +20,7 @@ function getProviders(): any[] {
}

@NgModule({
imports: [ ModalModule, CommonModule, FormsModule ],
imports: [ ModalModule, CommonModule ],
declarations: [
BSModalFooter,
BSMessageModalTitle,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, ViewEncapsulation } from '@angular/core';
import { AfterViewInit, Component, ElementRef, ViewChild, ViewEncapsulation } from '@angular/core';

import { DialogRef, ModalComponent } from '../../../../components/angular2-modal';

Expand Down Expand Up @@ -50,21 +50,28 @@ export class BSMessageModalTitle {
template: `<div [ngClass]="context.bodyClass">
<div [innerHtml]="context.message"></div>
<div *ngIf="context.showInput" class="form-group">
<input autofocus
<input autofocus #input
name="bootstrap"
type="text"
class="form-control"
[(ngModel)]="context.defaultValue"
(change)="context.defaultValue = input.value"
placeholder="{{context.placeholder}}">
</div>
</div>
`
})
export class BSMessageModalBody {
export class BSMessageModalBody implements AfterViewInit {
private context: MessageModalPreset;
@ViewChild('input') private inputElement: ElementRef;
constructor(public dialog: DialogRef<MessageModalPreset>) {
this.context = dialog.context;
}

ngAfterViewInit() {
const ctx = this.context as any;
if (ctx.showInput && this.inputElement && ctx.defaultValue != null)
this.inputElement.nativeElement.value = ctx.defaultValue;
}
}


Expand Down

0 comments on commit 07fcce8

Please sign in to comment.