User Interface Dialogs
NativeScript lets you create dialogs in your app in a manner similar to the web browser. You can create alerts, confirmations, prompts, logins and dialogs that require action.
NOTE: You can call dialog functions with parameters similar to the web browser API or the
options
object. All dialog functions return aPromise
object. In both iOS and Android, dialogs will not block your code execution!TIP: You can try this NativeScript Playground project to see all of this article’s examples in action on your device.
Alert
Web browser style
Using an options object
Confirm
Web browser style
Using an options object
The dialog result argument is Boolean. The result is true if the dialog is closed with the OK button. The result is false if closed with the Cancel button. The result is undefined if closed with a neutral button.
Prompt
Web browser style
Using an options object
The dialog result argument is an object with two properties: result and text (entered text). The result property is true if the dialog is closed with the OK button, false if closed with the Cancel button or undefined if closed with a neutral button.
Login
Web browser style
Using an options object
The dialog result argument is an object with three properties: result, userName and password (entered user name and password). The result property is true if the dialog is closed with the OK button, false if closed with the Cancel button or undefined if closed with a neutral button.
Action
Web browser style
Using an options object
The dialog result argument is a string (the text of the clicked option or the text of the cancel button).