0

I'm trying to make my first AngularJS project. I'm having problems with the project configuration. First i created a Java project AngularJSExample. Then I converted it to AngularJS project.I have configured script paths for Tern projects. The hello.html doesn't know what is greeting. Can you please tell me why?

These are my files:

<html ng-app> <head> <script src="angular.js"></script> <script src="controllers.js"></script> </head> <body> <div ng-controller='HelloController'> <p>{{greeting.text}}, World</p> </div> </body> </html> var myController = angular.module('myApp',[]); myController.controller('HelloController', ['$scope', function($scope) { $scope.greeting ={ text : 'Hello' }; }]); 
1
  • This didn't help. I have this in my console: Tern request#angular_type: {"query":{"type":"angular","subtype":"type","angularTypes":["module"],"expressio‌​n":"myApp","scope":{},"files":["projectFolders/js/controllers.js"]}} {"type":"Module","name":"myApp","origin":"projectFolders/js/controllers.js","ang‌​ularType":"module","module":"myApp"} Tern response#angular_type with 23ms: Tern request#angular_type: {"query":{"type":"angular","subtype":"type","angularTypes":["controller"],"expre‌​ssion":"HelloController","scope":{"module":"myApp"},"files":["projectFolders/js/c‌​ontrollers.js"]}} Commented Sep 23, 2014 at 12:48

2 Answers 2

1

Assuming you're using the current stable version of AngularJS, 1.2.25, you need to add the app name to the ng-app directive. So, your markup must be:

<html ng-app="myApp"> 

Working JS Bin

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

10 Comments

This didn't help. I have this in my console: Tern request#angular_type: {"query":{"type":"angular","subtype":"type","angularTypes":["module"],"expression":"myApp","scope":{},"files":["projectFolders/js/controllers.js"]}} {"type":"Module","name":"myApp","origin":"projectFolders/js/controllers.js","angularType":"module","module":"myApp"} Tern response#angular_type with 23ms: Tern request#angular_type: {"query":{"type":"angular","subtype":"type","angularTypes":["controller"],"expression":"HelloController","scope":{"module":"myApp"},"files":["projectFolders/js/controllers.js"]}}
I just took your code and put it into JSBin then added myApp to ng-app, and it works in the sample. If you don't see "Hello, World!" you must have other errors somewhere. By the way, that stuff you have in console doesn't looks like an error.
This is how my hello.html file looks like when I open it with a browser. {{greeting.text}}, World
check your inclusions: angular.js and controllers.js. Are the path correct?
I have a project that is called AngularJSExample. It has a src folder, JRESystemLibrary and a folder which I created, it is called projectFolders. In my projectFolders I have a html and a js folder. Html folder contains a hello.html file and js folder contains controllers.js. I have configured in project properties tern Script path. It is a folder named js - AngularJSExample/projectFolders and has a controllers.js. And I removed <script src="angular.js"></script>. Now I have <script src="ajax.googleapis.com/ajax/libs/angularjs/1.0.4/angular.min.js"> </script>.
|
0

This question is about AngularJS Eclipse.

At first, your script must be included inside script element. I have tested with this HTML file :

<html ng-app='myApp'> <head> <script src="angular.js"></script> <script src="controllers.js"></script> </head> <body> <div ng-controller='HelloController'> <p>{{greeting.text}}, World</p> </div> </body> </html> <script> var myController = angular.module('myApp',[]); myController.controller('HelloController', ['$scope', function($scope) { $scope.greeting ={ text : 'Hello' }; }]); </script> 

and everything works well :

  • completion on module, controller, expression (greeting)
  • hover on module, controller, expression (greeting)

I think your problem is about Ctrl+Space inside expression. You must see HTML elements <a>, <abr>, and greeting is on the bottom of the completion. To change this order, please read HTML Angular Tag Proposals

1 Comment

Ok, tnx, do you maybe know why I got this in my console Nodejs Commnand: "D:\eclipse-jee-luna\plugins\tern.eclipse.ide.server.nodejs.embed.win32.win32.x86_64_0.5.0.201409012129\node-v0.10.22-win32-x86_64\node.exe" "D:\eclipse-jee-luna\plugins\tern.core_0.5.0.201409012129\node_modules\tern\bin\tern" --no-port-file Project dir: D:\AngularJSWorkspace\AngularJSExample null Why null?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.