Alert Message Not getting Displayed in Android Emulator


#1

Hello, I am currently making Android Applicatin using IONIC framework, I just created sample Application using below commands

  1. Ionic start HelloWorld
  2. cd helloworld
  3. ionic build android
  4. ionic emulate android.

I am able to run app successfully on emulator. Now, I added a hyperlink a tab-dash.html (this file will be created by default). Now, i added a js file called “tab-dash.js” and added below code. I referenced jquery-1.7.2.min.js also.
tab-dash.js

$(function() {
$('#reset').on('click', function() {
   	alert("Hello World");
	});	
  });

this is how my tab-dash.html looks like:

<!DOCTYPE html>
<html>
  <head>
  <script type="text/javascript" src="../js/jquery-1.7.2.min.js"></script>
  <script src="../js/tab-dash.js"></script>
  </head>

<ion-view title="Dashboard">
  <ion-content class="has-header padding">
    <h1>Dash AIS</h1>
     <div class="span4">
            <div class="well">
                <a id="reset" href="#" class="btn"><i class="icon-trash"></i> Hello World</a>
               </div>
        </div>
  </ion-content>
</ion-view>
</html>

When I run this code in browser i am able to see alert box. But, when I tried in emulator I am not. Any idea what I am doing wrong here? I am new to Javascript and PhoneGap too.

Thanks.


#2

Any Help? I am still having the same issue.


#3

Why are you using jQuery to do click detection?

Try using ng-click

<a href="#" class="btn" ng-click="alert('Hello!')"><i class="icon-trash"></i> Hello World</a>

#4

Thank You. I was resolved this issues after watching angularjs tutorial since morning.

Thanks much.