2017-04-12 68 views
1

我試圖用ngx模塊實現一個窗口模態,但是當它打開窗口它停留在背景和屏幕被禁用。模態窗口留在後臺(ngx模式)

這裏是我的代碼:

<button md-raised-button color="primary" class="text-upper" (click)="firstModal.open()">Proveedor</button> 
<modal #firstModal> 
    <modal-header> 
     <h1>I am first modal</h1> 
    </modal-header> 
    <modal-content> 
     This modal has its own header, content and footer. 
    </modal-content> 
    <modal-footer> 
     <button class="btn btn-primary" click="firstModal.close()">okay!</button> 
    </modal-footer> 
</modal> 
<button md-raised-button color="primary" class="text-upper">Marca</button> 
</div> 

Image

With opacity:0

感謝。

+0

難道你發佈的瀏覽器控制檯日誌? –

+0

嗨,謝謝你的回答。我在日誌中沒有錯誤,只有警告。 – Leonardo

+0

@Leonardo下面的答案幫助你? – Aravind

回答

0

您應該使用opacity:0 CSS屬性如下

import {ModalModule} from "ngx-modal"; 
@Component({ 
    selector: 'my-app', 
    template: ` 
    <div [class.disable]="disable"> 
     <h2>Hello {{name}}</h2> 
     <div class="row container-fluid"> 
     <img height="400" src="http://lorempixel.com/400/200"/><br><br> 
    <button (click)="openClicked()"> open my modal</button> 
    <br/><br/><br/><br/><br/><br/> 

    </div> 
</div> 
    <modal #myModal> 
     <modal-header> 
      <h1>Modal header</h1> 
     </modal-header> 
     <modal-content> 
      Hello Modal! 
     </modal-content> 
     <modal-footer> 
      <button class="btn btn-primary" (click)="closeClicked()">close</button> 
     </modal-footer> 
    </modal> 


    `, 
}) 
export class App { 
    @ViewChild('myModal') myModal; 
    name:string; 
    constructor() { 
    this.name = 'Angular2' 
    } 
    openClicked(){ 
    this.disable=true; 
    this.myModal.open(); 
    } 
    closeClicked(){ 
    this.disable=false; 
    this.myModal.close(); 
    } 
} 

LIVE DEMO

+0

感謝@Aravind的幫助。我做了你所說的,看起來模態在前面,但是出於任何原因dosnt工作。打開模式時頁面保持禁用狀態。 – Leonardo

+0

@Leonardo你想讓模態被禁用? – Aravind

+0

@arvind我添加了圖片和結果。在我打開模式之後,我無法再與該頁面進行交互,而只需刷新該頁面。 – Leonardo