Help get this topic noticed by sharing it on Twitter, Facebook, or email.
I’m sad

Angular JS Up and Running.. Unfortunately not. Going wrong in chapter 3

Angular JS Up & Running: Chapter 3. I have done all it says in this chapter but when I run karma run I do get errors instead of successful response:
Safari 7.0.6 (Mac OS X 10.9.4) ERROR
ReferenceError: Can't find variable: angular
at /Users/werner/Documents/workspace/BreadAndCoffee/js/controller.js:2

Which seems logical because Angular.js is never called/referenced or mentioned anywhere. So my question: What did I miss?
1 person has
this question
+1
Reply
  • Hello Werner,

    I have forwarded your question on to our Book Tech staff, so they can help you find a solution. If you ever have any questions or issues with the content of a title, you can also contact them directly at booktech@oreilly.com or call them at:

    1-800-889-8969
    or
    1-707-827-7019 (outside the USA)
    7:30 am to 5:00 PST

    Best regards,
    Paul Fichera
    O'Reilly Media
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited kidding, amused, unsure, silly indifferent, undecided, unconcerned sad, anxious, confused, frustrated

  • 1
    Hi Werner,

    Thanks for trying out the book.

    With chapter3, can you please check your karma.conf.js? That seems to be the most likely culprit. If you look at pg 39 of the book, which has the karma.conf.js code, you will see a line which says

    files: [
    'angular.min.js',
    'angular-mocks.js',
    'controller.js',
    'simpleSpec.js',
    'controllerSpec.js'
    ]

    This should ensure that the angular.min.js is loaded before the controller.js is loaded.

    You can grab the correct version of the karma.conf.js file from https://github.com/shyamseshadri/angu... to make sure there are no problems.

    Or you can grab the entire chapter3 folder from https://github.com/shyamseshadri/angu...

    Also, ensure you are running karma from the same folder as the config file, or point to it manually. This could be the other problem, that the karma.conf.js is in a different folder, or the paths in it are not correctly mentioned.

    Let me know if this helped.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited kidding, amused, unsure, silly indifferent, undecided, unconcerned sad, anxious, confused, frustrated

  • I’m thankful
    The files I missed. Now it is working. It was not clear for me from the text that I should have included that. I just did karma init but wasn't aware that I needed the angular files I just added js/*.js and thought that would be enough.

    Thanks for the help.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited kidding, amused, unsure, silly indifferent, undecided, unconcerned sad, anxious, confused, frustrated