javascript - Ionic/AngularJS ng-click event not firing? -
i playing around withe ionic/angularjs. can't alert window show ? started ionic blank template. app launches in browser window, when button pressed, nothing happens.
// ionic starter app // angular.module global place creating, registering , retrieving angular modules // 'starter' name of angular module example (also set in <body> attribute in index.html) // 2nd parameter array of 'requires' var app = angular.module('freshlypressed', ['ionic']); app.run(function($ionicplatform) { $ionicplatform.ready(function() { // hide accessory bar default (remove show accessory bar above keyboard // form inputs) if(window.cordova && window.cordova.plugins.keyboard) { cordova.plugins.keyboard.hidekeyboardaccessorybar(true); } if(window.statusbar) { statusbar.styledefault(); } }); }); app.controller( 'appctrl' , function($scope, $log) { $scope.refresh = function() { window.alert("hello"); } });
<!doctype html> <html data-ng-app="freshlypressed" data-ng-control="appctrl"> <head> <meta charset="utf-8"> <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width"> <title>freshly pressed</title> <link href="lib/ionic/css/ionic.css" rel="stylesheet"> <link href="css/style.css" rel="stylesheet"> <!-- if using sass (run gulp sass first), uncomment below , remove 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 404 during development) --> <script src="cordova.js"></script> <!-- app's js --> <script src="js/app.js"></script> </head> <body> <ion-header-bar class="bar-balanced"> <h1 class="title">freshly pressed</h1> <button type="button" class="button" ng-click="refresh()"> <i class="icon ion-refresh"></i> </button> </ion-header-bar> <ion-content> <h1>some contents</h1> </ion-content> </body> </html>
unless ionic different angular, have data-ng-control
, should data-ng-controller
.
Comments
Post a Comment