spModal - 클라이언트
위젯에 서비스 포털 경보, 프롬프트 및 확인 대화 상자를 표시합니다. spModal 클래스는 클라이언트 스크립트에서 서비스 포털 사용할 수 있습니다.
spModal 클래스는 Angular UI 부트 스트랩의 $uibModal에 대한 경량 래퍼입니다. spModal.open() 메서드를 사용하여 모달 대화 상자에 위젯을 표시할 수 있습니다.
spModal - alert(문자열 메시지).then(fn)
경보를 표시합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 메시지 | 문자열 | 표시할 메시지입니다. |
| 유형 | 설명 |
|---|---|
| 부울 | Promise에는 true 또는 false를 포함하는 단일 인수가 포함되어 있습니다. |
// HTML template
<button ng-click="c.onAlert()" class="btn btn-default">
Alert
</button>
// Client script
function(spModal) {
var c = this;
c.onAlert = function () {
spModal.alert('How do you feel today?').then(function (answer) {
c.simple = answer;
});
}
}
spModal - confirm(문자열 메시지).then(fn)
확인 메시지를 표시합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 메시지 | 문자열 | 표시할 메시지입니다. |
| 유형 | 설명 |
|---|---|
| 부울 | Promise에는 true 또는 false를 포함하는 단일 인수가 포함되어 있습니다. |
// HTML template
<button ng-click="c.onConfirm()" class="btn btn-default"> Confirm </button>
<span>{{c.confirmed}}</span>
// Client script
function(spModal) {
var c = this;
c.onConfirm = function() {
c.confirmed = "asking";
spModal.confirm("Can you confirm or deny this?").then(function(confirmed) {
c.confirmed = confirmed; // true or false
})
}
}
HTML 메시지로 확인:
//HTML template
<button ng-click="c.onConfirmEx()" class="btn btn-default">
Confirm - HTML message
</button>
<span>{{c.confirmed}}</span>
// Client script
function(spModal) {
var c = this;
// more control, passing options
c.onConfirmEx = function() {
c.confirmed = "asking";
var warn = '<i class="fa fa-warning" aria-hidden="true"></i>';
spModal.open({
title: 'Delete this Thing?',
message: warn + ' Are you <b>sure</b> you want to do that?'
}).then(function(confirmed) {
c.confirmed = confirmed;
})
}
}
spModal - 열기(객체 옵션).then(fn)
지정된 옵션을 사용하여 모달 창을 엽니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 옵션 | 객체 | 이러한 속성을 가질 수 있는 객체입니다.
|
| 유형 | 설명 |
|---|---|
| void |
다음 코드 예제에서는 레이블이 있는 프롬프트를 만드는 방법을 보여 줍니다.
//HTML template
<button ng-click="c.onOpen()" class="btn btn-default">
Prompt with label
</button>
<div ng-show="c.name">
You answered <span>{{c.name}}</span>
</div>
//Client code
function(spModal) {
var c = this;
c.onOpen = function() {
//ask the user for a string
spModal.open({
title: 'Give me a name',
message: 'What would you like to name it?',
input: true,
value: c.name
}).then(function(name) {
c.name = name;
})
}
}
다음 코드 예제에서는 사용자 지정 단추 옵션을 사용하는 방법을 보여 줍니다.
//HTML template
<button ng-click="c.onAgree()" class="btn btn-default">
Agree
</button>
<div ng-show="c.agree">
You answered {{c.agree}}
</div>
//Client script
function(spModal) {
var c = this;
c.onAgree = function() {
// ask the user for a string
// note embedded html in message
var h = '<h4>Apple likes people to agree to lots of stuff</h4>'
// Line feeds added to the following lines for presentation formatting.
var m = 'Your use of Apple software or hardware products is based
on the software license and other terms and conditions in effect for the
product at the time of purchase. Your agreement to these terms is required
to install or use the product. '
spModal.open({
title: 'Do you agree?',
message: h + m,
buttons: [
{label:'✘ ${No}', cancel: true},
{label:'✔ ${Yes}', primary: true}
]
}).then(function() {
c.agree = 'yes';
}, function() {
c.agree = 'no';
})
}
}
다음 코드 예제에서는 포함된 위젯 옵션을 사용하는 방법을 보여 줍니다.
//HTML template
<button ng-click="c.onWidget('widget-cool-clock')" class="btn btn-default">
Cool Clock
</button>
//Client script
function(spModal) {
var c = this;
c.onWidget = function(widgetId, widgetInput) {
spModal.open({
title: 'Displaying widget ' + widgetId,
widget: widgetId,
widgetInput: widgetInput || {}
}).then(function(){
console.log('widget dismissed');
})
}
}
spModal - prompt(문자열 메시지, 문자열 기본값).then(fn)
사용자 입력에 대한 프롬프트를 표시합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 메시지 | 문자열 | 표시할 메시지입니다. |
| 기본값(선택 사항) | 문자열 | 사용자가 응답을 제공하지 않는 경우 사용할 기본값입니다. |
| 유형 | 설명 |
|---|---|
| 문자열 | promise에는 사용자의 응답이 포함되거나 사용자가 응답을 입력하지 않은 경우 기본값이 포함됩니다. |
//HTML template
<button ng-click="c.onPrompt()" class="btn btn-default">
Prompt
</button>
<div ng-show="c.name">
You answered <span>{{c.name}}</span>
</div>
// Client script
function(spModal) {
var c = this;
c.onPrompt = function() {
spModal.prompt("Your name please", c.name).then(function(name) {
c.name = name;
})
}
}