使用AngularJs不起作用的离子警报框

时间:2015-09-01 14:55:36

标签: angularjs ionic

我想使用角度js在离子中创建警告框但是当我单击警报按钮时没有任何反应。请指点我。 这是我的index.html

<!DOCTYPE html>
<html lang="en" data-ng-app="ionicApp">
<head>

  <meta charset="utf-8">
  <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">

  <title>Ionic-AngularJS-Cordova</title>

  <!-- Ionic framework - replace the CDN links with local files and build -->    
  <link href="lib/ionicframework/ionic.min.css" rel="stylesheet">
    <link href="http://code.ionicframework.com/1.1.0/css/ionic.css" rel="stylesheet">

  <script src="lib/ionicframework/ionic.bundle.min.js"></script>

  <script src="js/app.js"></script>

  <script src="cordova.js"></script>

  <style>
      .box {height:300px;padding: 10px}
  </style>      
</head>

<body data-ng-controller="AppCtrl">
<ion-header-bar class="bar-balanced">

  <h1 class="title">Welcome to my web app</h1>
    <button class="button" data-ng-click="refresh()">
        <i class="icon ion-refresh"></i>
    </button>

</ion-header-bar>

<ion-content>

    <h1>Some Content</h1>


</ion-content>

<div class="bar bar-footer">
  <button class="button button-clear">Left</button>
  <div class="title">Title</div>
  <button class="button button-clear">Right</button>
</div>


</body>
</html>

这是我的app.js

angular.module('ionicApp', ['ionic'])

 .controller('AppCtrl', function() {

  ionic.Platform.ready(function() {
    navigator.splashscreen.hide();
  });

 });

function AppCtrl($scope, $log){

    $scope.refresh = function(){

    alert("Button Pressed");

    }

}

单击刷新按钮时,我希望弹出窗口。

1 个答案:

答案 0 :(得分:0)

我能够用这个来解决我的问题:

angular.module('ionicApp', ['ionic'])

 .controller('AppCtrl', function($scope) {


$scope.refresh = function(){
    alert("Button Pressed");
    };      

  ionic.Platform.ready(function() {
    navigator.splashscreen.hide();
  });

 });

问候。