1
대화 상자가 약 1 초 동안 표시된 다음 숨 깁니다. 아마도이 옵션 "autoCloseTimeout"을 사용하여 제한 시간을 1 ~ 2 분으로 설정할 수 있었지만이 문제에 대한 더 깨끗한 해결책이 있기를 바라고 있습니다. 나는 팝업이 초점을 잃고 있기 때문에 이것이 발생했다는 한 가지 의견을 보았다. 나는 팝업에 텍스트 박스를 놓고 그것을 즉시 클릭함으로써 이것을 배제했다.ng2-bootstrap-modal이 즉시 닫힙니다.
import { Component } from '@angular/core';
import { DialogComponent, DialogService } from "ng2-bootstrap-modal";
export interface ConfirmModel {
title: string;
message: string;
}
@Component({
selector: 'confirm',
template: `<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" (click)="close()" >×</button>
<h4 class="modal-title">{{title || 'Confirm'}}</h4>
</div>
<div class="modal-body">
<p>{{message || 'Are you sure?'}}</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" (click)="confirm()">OK</button>
<button type="button" class="btn btn-default" (click)="close()" >Cancel</button>
</div>
</div>
</div>`
})
export class ConfirmComponent extends DialogComponent<ConfirmModel, boolean> implements ConfirmModel {
title: string;
message: string;
constructor(dialogService: DialogService) {
super(dialogService);
}
confirm() {
// we set dialog result as true on click on confirm button,
// then we can get dialog result from caller code
this.result = true;
this.close();
}
}
나는 다음과 같은 버전을 사용하고 있습니다 :
여기 여기 타이프 스크립트 구성 요소
showConfirm(blkId: string) {
let disposable = this.dialogService.addDialog(ConfirmComponent, {
title: 'Confirm title',
message: 'Confirm message'
})
.subscribe((isConfirmed) => {
//We get dialog result
if (isConfirmed) {
alert('accepted');
}
else {
alert('declined');
}
});
//We can close dialog calling disposable.unsubscribe();
//If dialog was not closed manually close it by timeout
setTimeout(() => {
disposable.unsubscribe();
}, 4000); //changign this value has no affect
}
여기 ConfirmDialog 구성 요소 소스의의 방법이다 html로
<span>
<a href="#" title="Delete" class="myItem"
(click)="showConfirm(item.id)">
<span class='glyphicon glyphicon-trash toolbarItem'></span>
</a>
</span>
의 각도 2.4.5, 각도 2 플랫폼 -node, ~ 2.0.11 부트 스트랩 :^3.3.7
제목에 표시된대로 ng2-bootstrap을 사용하고 있습니다. 첫 번째 문장은 나에게 아이디어를 제공하는 데 도움이되었습니다. 다음과 같은 변경을하면 지금 가능한 해결책이되었습니다. setTimeout (() => { disposable.unsubscribe(); }, 333000); // 아주 긴 시간 return false; // 링크 "#"가 탐색되는 것을 방지합니다. 기본적으로 페이지를 다시로드합니다. 또한 javascrippt 라이브러리에 대한 중복 참조가이 동작을 일으킬 수있는 ng1.x에 대한 언급을 보았습니다.하지만 여기서는 그렇지 않습니다. – Ironmantra
그래서 당신이하려고하는 것은 무엇입니까? – Aravind
@ 아이언 맨트라 upvote 너무 :) – Aravind