Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript AngularJS Basics (1.x) Controllers and Scope Creating a Controller

Leor Benari
Leor Benari
628 Points

Not Getting Any Output in Preview

I believe that I followed along with what Huston was doing, but I'm not getting any output when I preview this. I have included a snapshot of my workspace below:

https://w.trhou.se/r7p3t926av

Thanks!

2 Answers

Steven Parker
Steven Parker
229,744 Points

Without forking your snapshot, I spotted a couple of potential issues right off:

  • your HTML tries to include a script file "hello-world.js", but there is no such file in your snapshot
  • there is a stray equal-sign (=) in the type attribute of that same script line
Leor Benari
Leor Benari
628 Points

Thank you, I am relatively new to this - Hopefully, I'll be able to catch the next one on my own!

Nailed it. I had the same problem for a bit and was hitting my head against the wall. Watch the bit where he talks about scope again. You'll hear him mention that the scope of the mainCtrl controller is limited to the div that it is applied to. This means that for your helloWorld() function to work IT MUST BE BETWEEN THE TAGS that you applied ng-controller="mainCtrl" to. Or simply: in your index file, cut the content on lines 18-24, add a line between 15-16 and plop it there.