Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/424.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 离子倒计时应用程序_Javascript_Angularjs_Ionic - Fatal编程技术网

Javascript 离子倒计时应用程序

Javascript 离子倒计时应用程序,javascript,angularjs,ionic,Javascript,Angularjs,Ionic,我用ionic编写了一个倒计时应用程序,我不擅长AngularJS,正因为如此,我不知道我做错了什么:/ 也许你可以看看我的代码,它应该有一个按钮,开始倒计时,如果倒计时结束,应该会弹出一条消息 timer.js app.js //Ionic Starter应用程序 //angular.module是创建、注册和检索angular模块的全局位置 //“starter”是此角度模块示例的名称(也在index.html中的属性中设置) //第二个参数是“requires”的数组 角度模块('star

我用ionic编写了一个倒计时应用程序,我不擅长AngularJS,正因为如此,我不知道我做错了什么:/ 也许你可以看看我的代码,它应该有一个按钮,开始倒计时,如果倒计时结束,应该会弹出一条消息

timer.js app.js
//Ionic Starter应用程序
//angular.module是创建、注册和检索angular模块的全局位置
//“starter”是此角度模块示例的名称(也在index.html中的属性中设置)
//第二个参数是“requires”的数组
角度模块('starter',['IONAL']))
.run(函数($ionicPlatform){
$ionicPlatform.ready(函数(){
if(window.cordova&&window.cordova.plugins.Keyboard){
//默认情况下隐藏附件栏(删除此选项可在键盘上方显示附件栏)
//表格输入)
插件键盘hideKeyboardAccessoryBar(真);
//除非您知道自己在做什么,否则不要删除此行。它会停止视口
//当文本输入被聚焦时,从捕捉。Ionic在内部为
//更好的键盘体验。
插件。键盘。禁用滚动(真);
}
如果(窗口状态栏){
StatusBar.styleDefault();
}
});
})
index.html

比萨饼计时器
警觉的
如果查看,您将看到它的第一个参数是一个函数,应该在指定的延迟后调用该函数

延迟(第二个参数)以毫秒为单位指定。因此,要在5秒钟后显示警报,您的
$sope.timerCountdown
函数如下所示:

$scope.timerCountdown = function(res){
  var endtimer = $timeout(
    function() {
      var alertPopup = $ionicPopup.alert({
       title: 'Your Pizza Is Ready!',
       template: 'Bon Appétit!'});
    },
    5000);
};

但它仍然会给我错误,并且不会向上显示应用程序(链接:)@JulianBe:不知道问题出在哪里,它一定是在应用程序的另一部分(不是在Timer Countdown中)。看看这个最小的例子:-也许你能看到区别。我还有一个问题,你知道我如何显示剩余的时间吗?
    // Ionic Starter App

// angular.module is a global place for creating, registering and retrieving Angular modules
// 'starter' is the name of this angular module example (also set in a <body> attribute in index.html)
// the 2nd parameter is an array of 'requires'
angular.module('starter', ['ionic'])

.run(function($ionicPlatform) {
  $ionicPlatform.ready(function() {
    if(window.cordova && window.cordova.plugins.Keyboard) {
      // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
      // for form inputs)
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);

  // Don't remove this line unless you know what you are doing. It stops the viewport
  // from snapping when text inputs are focused. Ionic handles this internally for
  // a much nicer keyboard experience.
  cordova.plugins.Keyboard.disableScroll(true);
}
if(window.StatusBar) {
  StatusBar.styleDefault();
}


 });
})
    <!DOCTYPE html>
<html ng-app="PopupTimer">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    <title></title>

    <link href="lib/ionic/css/ionic.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">

    <!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above
    <link href="css/ionic.app.css" rel="stylesheet">
    -->

    <!-- ionic/angularjs js -->
    <script src="lib/ionic/js/ionic.bundle.js"></script>

    <!-- cordova script (this will be a 404 during development) -->
    <script src="cordova.js"></script>

    <!-- your app's js -->
    <script src="js/app.js"></script>
    <script src="js/timer.js"></script>
  </head>
  <body ng-app="starter">

    <ion-pane>
      <ion-header-bar align-title="center" class="bar-assertive">
        <h1 class="title">Pizza Timer</h1>
      </ion-header-bar>
      <ion-content ng-controller="PopupCtrl">
        <button class="button button-full button-light" ng-click="timerCountdown">
          Alert
        </button>
      </ion-content>    
    </ion-pane>
  </body>
</html>
$scope.timerCountdown = function(res){
  var endtimer = $timeout(
    function() {
      var alertPopup = $ionicPopup.alert({
       title: 'Your Pizza Is Ready!',
       template: 'Bon Appétit!'});
    },
    5000);
};