0

I want to run a simple Angular js code but I am not able to do it in Cordova with Onsen ui

I am getting an error link below :

https://docs.angularjs.org/error/ng/areq?p0=HelloCtrl&p1=not%20a%20function,%20got%20undefined

I am referring this page :

https://onsen.io/blog/onsen-ui-tutorial-angularjs-essentials-for-using-onsen-ui-part-1/

Using Onsen 1

p1.html:

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
<meta http-equiv="Content-Security-Policy"/>
<link href="css/bootstrap.min.css" rel="stylesheet"> 
<link rel="stylesheet" href="css/onsenui.css">
<link rel="stylesheet" href="css/onsen-css-components.css">
<link rel="stylesheet" href="css/sliding_menu.css">
<link rel="stylesheet" type="text/css" href="css/index.css">
<script src="js/jquery.js"></script> 
<script src="js/bootstrap.min.js"></script>
<script src="js/angular/angular.min.js"></script>
<script type="text/javascript" src="cordova.js"></script>

 <script>

 ons.bootstrap();

 var myApp = angular.module('myApp',[]);

 myApp.controller('HelloCtrl', function($scope){
     $scope.name = "Onsen UI!";
 });

</script>
</head>
<body ng-app="myApp">
<div ng-controller="HelloCtrl">
<input type="text" ng-model="name">
<p>Hello {{name}}</p>
</div> 
</body>
</html>

Output :

enter image description here

Error :

enter image description here

Below is my Directory structure :

enter image description here

4
  • able to run the exact same code without any error? Could you let me where you are trying to run this html? In browser or device? Commented Apr 18, 2016 at 15:13
  • @Gandhi I am using Android Emulator for testing Commented Apr 20, 2016 at 6:31
  • can you share your complete project so that i can test it on a device? Commented Apr 20, 2016 at 7:11
  • I have added my directory structure in case I am doing some mistakes Commented Apr 20, 2016 at 7:21

2 Answers 2

1

You will have to include jQuery in your project, this is what the error is all about.

Error: Bootstrap's Javascript requires jQuery

Also make sure to load jquery.js file before loading bootstrap

Sign up to request clarification or add additional context in comments.

3 Comments

I have installed jquery which .js files I need to link in my html page
@AshishShukla just like you did with angular.js src="https://code.jquery.com/jquery-2.2.3.js">
I added your jquery link but stil no output
1

Solved It...

Actually when I installed jquery I copied only the jquery.js file from the jquery folder into my js folder but now I copied the whole jquery folder into the js folder and It executed successfully...

Thanks for your support guys.

1 Comment

i am glad you did it mate :D

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.