Angularjs 设定时间后自动关闭的onsen通知

Angularjs 设定时间后自动关闭的onsen通知,angularjs,cordova,notifications,onsen-ui,auto-close,Angularjs,Cordova,Notifications,Onsen Ui,Auto Close,嗨,我正在使用Onsen作为AngularJS Phonegap/Cordova项目的一部分 我想知道是否有可能在设定的时间后自动关闭Onsen通知。也可以不包括按钮吗 我当前的通知如下所示: var notifyAutoClose = function(title, message) { var options = { title: title, message: message, buttonLabel:

嗨,我正在使用Onsen作为AngularJS Phonegap/Cordova项目的一部分

我想知道是否有可能在设定的时间后自动关闭Onsen通知。也可以不包括按钮吗

我当前的通知如下所示:

var notifyAutoClose = function(title, message) {
        var options = {
            title: title,
            message: message,
            buttonLabel: '', //Don't show button if possible
            animation: 'default'
        };
        ons.notification.alert(options);            
    }
如果不可能,在使用AngularJS时,最好的非自举替代方案是什么


非常感谢您抽出时间

您应该使用
ons dialog
指令创建自定义对话框

检查以下代码():

//HTML
对话
自定义对话框
{{title}}

{{message}

//JAVASCRIPT ons.bootstrap() .controller('DialogController',函数($scope){ $scope.show=函数(dlg、标题、消息){ $scope.title=标题; $scope.message=消息; 创建对话框(dlg,{parentScope:$scope}){ dialog.show(); }); setTimeout(函数(){dialog.hide()},2000) } });
//HTML
<ons-page>
    <ons-toolbar>
      <div class="center">Dialog</div>
    </ons-toolbar>
    <ons-list ng-controller="DialogController">
      <ons-list-item ng-click="show('customdialog.html','Dialog title', 'it will close after 2 seconds')" modifier="tappable">
         Custom dialog
      </ons-list-item>
   </ons-list>
</ons-page>

<ons-template id="customdialog.html">
   <ons-dialog var="dialog" modifier="android">
     <ons-toolbar modifier="android">
       <div class="center">{{title}}</div>
     </ons-toolbar>
     <p style="text-align:center;margin-top:50px">{{message}}</p>
  </ons-dialog> 
 </ons-template>

//JAVASCRIPT
ons.bootstrap()
.controller('DialogController', function($scope) {
   $scope.show = function(dlg,title,message) {
      $scope.title=title;
      $scope.message=message;
     ons.createDialog(dlg,{parentScope:$scope}).then(function(dialog) {
        dialog.show();
     });
     setTimeout(function(){dialog.hide()},2000)
   }
 });