0

Trying to write first angular app using node.js, express, and jade. So I know it must be something very simple but I have been stuck for a while.

I included angular js ( route using the CDN in the head section of the jade(html) template. As indicated bellow:

link(href='https://ajax.googleapis.com/ajax/libs/angularjs/1.2.14/angular.js')
link(href='https://ajax.googleapis.com/ajax/libs/angularjs/1.2.14/angular-route.js')

I also tried switching from the angular.js in the CDN to a plain include in my own server, without any positive results to my problem. I use the directive ng-app='myApp' in the html tag of the template (also tried in the body tag after the head includes). I also include myApp in the head section of the jade (or html) template using:

script(src='/webapp/js/myApp.js')

The code in myApp.js looks like this:

var myApp=angular.module('myApp', [
  'ngRoute'
]).config(['$routeProvider', function($routeProvider) {
...
}]);

I keep getting the console error:

ReferenceError: Can't find variable: angular

globalcode - myApp.js:2

1 Answer 1

1

The error means that angular isn't loaded, it doesn't know what angular is.

When learning a new technology stack you should approach each piece individually. You can learn the basics of Angular using plnkr.co as the basis for testing those bits of code quickly and easily here's a very simple plnkr to get you started:

http://plnkr.co/edit/WU6y8ka0udXHzZvCeZPc

You can use the find external libraries button on the right side to add in commonly used libraries.

Once you understand how to work with Angular by itself in isolation you can scratch that off the list of possible problems.

Angular needs to be loaded before your script that references angular is loaded so the next step would be using the debug panel (F12) to see the network calls and figure out why angular isn't being loaded.

To test your back-end manually you can use the POSTMan chrome plugin (or curl if you're into that) to test out the server side response to various requests in isolation from the angular code.

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.