I would like to use the alert dialog in the Onsen UI Minimal Template. How can I apply the HTML and JS source code in the Onsen UI Minimal Template to output the alert dialog?
index.html
<script>
ons.bootstrap();
</script>
<script>
ons.bootstrap();
.controller('NotificationController', function($scope){
$scope.alert=function(){
ons.notification.alert({message:'An error has occurred!'});
}
$scope.confirm=function(){
ons.notification.confirm({
message: 'Are you sure you want to continue?',
callback:function(idx){
switch(idx){
case0:
ons.notification.alert({
message: 'You pressed "Cancel".'
});
break;
case1:
ons.notification.alert({
message: 'You pressed "OK".'
});
break;
}
}
});
}
$scope.prompt=function(){
ons.notification.prompt({
message: "Please enter your age",
callback:function(age){
ons.notification.alert({
message: 'You are' + parseInt(age||0) + 'years old.'
});
}
});
}
});
</script>
Then the preview screen will be blank
Get rid of this and use page1.html
</ons-page>
immediately preceding the
<ons-list ng-controller="NotificationController">
<ons-list-item ng-click="alert()"modifier="tappable">
Alert
</ons-list-item>
<ons-list-item ng-click="confirm()"modifier="tappable">
Confirm
</ons-list-item>
<ons-list-item ng-click="prompt()"modifier="tappable">
Prompt
</ons-list-item>
</ons-list>
If you just add , the letter 。Alert Confirm Prompt と appears on the screen.
I think it's really rudimentary, but I'd appreciate it if you could give me an answer.
monaca onsen-ui
I think I can do it like this.
index.html
<script>
ons.bootstrap()
.controller('NotificationController', function($scope){
$scope.alert=function(){
ons.notification.alert({message:'An error has occurred!'});
}
$scope.confirm=function(){
ons.notification.confirm({
message: 'Are you sure you want to continue?',
callback:function(idx){
switch(idx){
case0:
ons.notification.alert({
message: 'You pressed "Cancel".'
});
break;
case1:
ons.notification.alert({
message: 'You pressed "OK".'
});
break;
}
}
});
}
$scope.prompt=function(){
ons.notification.prompt({
message: "Please enter your age",
callback:function(age){
ons.notification.alert({
message: 'You are' + parseInt(age||0) + 'years old.'
});
}
});
}
});
</script>
page1.html
<ons-page>
<ons-toolbar>
<div class="center"> Navigator</div>
</ons-toolbar>
<ons-list ng-controller="NotificationController">
<ons-list-item ng-click="alert()"modifier="tappable">
Alert
</ons-list-item>
<ons-list-item ng-click="confirm()"modifier="tappable">
Confirm
</ons-list-item>
<ons-list-item ng-click="prompt()"modifier="tappable">
Prompt
</ons-list-item>
</ons-list>
</ons-page>
You do not need a semicolon of ons.bootstrap();
in the code written in the question.
572 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
611 GDB gets version error when attempting to debug with the Presense SDK (IDE)
574 Who developed the "avformat-59.dll" that comes with FFmpeg?
578 Understanding How to Configure Google API Key
618 Uncaught (inpromise) Error on Electron: An object could not be cloned
© 2024 OneMinuteCode. All rights reserved.