I need help with MovieApp tutorial

I don’t know how to deploy the app in the ‘Creating RESTful APIs with Express 4’ tutorial https://www.sitepoint.com/creating-restful-apis-express-4/

Can someone help a newbie? I’ve tried node app.js and node services.js and I get ReferenceError: angular is not defined. I guess this is so obvious it’s not covered in the tutorial. Help a guy out.

My last tutorial focussed on creating a Single Page CRUD app with Angular’s $resource.

Prerequisites
The $resource service doesn’t come bundled with the main Angular script. You need to download a separate file called angular-resource.js and include it in your HTML page. The script can be downloaded from http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.16/angular-resource.min.js.

I guess the title could have been more clear with a “part 2” after it.
But it does usually help to start at the beginning :wink:

1 Like

Thanks for responding. I mis-typed there. The Creating a CRUD App in Minutes with Angular’s $resource tutorial is the one I’m talking about. I did the API part first and I got it up and running as described in the tutorial. I deployed that with node bin/www.

I have all the files in the file structure described. But I’m not sure what is meant by ‘Assuming the app is deployed under localhost/movieApp’. I know this must be something very simple that I’m overlooking. I would really appreciate the obvious being pointed out. I’m bewildered.

Thanks

You would likely run your node app using node bin/www

Is that what is throwing the error?

I don’t know how to deploy the app in the ‘Creating a CRUD App in Minutes with Angular’s $resource’ tutorial https://www.sitepoint.com/creating-crud-app-minutes-angulars-resource/

Not sure what is meant by ‘Assuming the app is deployed under localhost/movieApp’.

Can someone help a newbie? I’ve tried node app.js and node services.js and I get ReferenceError: angular is not defined. I guess this is so obvious it’s not covered in the tutorial. Help a guy out.

I just very briefly skimmed through the article, but this would assume some kind of server running on your localhost (e.g. a node server) for development purposes. As mentioned in the article, $resource expects a RESTful API, which you would then query like e.g. http://localhost/api/entries.

This means that Angular is not loaded, or in node-terms, hasn’t been required properly. However, running an Angular-app with node doesn’t make much sense anyway – it’s meant to run in the browser. I’d suspect it even depends on that (e.g. a node environment doesn’t have the window object or document).

Edit: Yup, throws a ReferenceError: window is not defined

@joebien,

Did you happen to download the movieApp.zip file from GitHub to see where you may have made a mistake?

Is your code in GitHub or a similar repository that we can see it? As I imagine there is something off with what you have coded.

Yes - I’m running the code from Github. If I load the index file I get

The Movie App Home

when I should get
http://movieapp-sitepointdemos.rhcloud.com/

The index file is missing things that are in the online working version. I guess I have to build the html up with angular directives . But I thought this was supposed to work out of the box.

Thanks for responding. Any thoughts are very welcome.

In the meantime, I’ve pinged the author of the article on one of Sitepoints private communication sites. Hopefully he gets it and can join this discussion to help you out!

If not, I’ll try to follow those articles this weekend and see if I run into the same problems you are hitting.

You are a saint. Thank you.

OK. I found my problem. A base tag in my html was preventing dependencies from loading. Now I have other problems, but that’s another story.

Thanks very much for replying.

1 Like

Oh, awesome! Let us know if the other problems become too much trouble and hopefully we can help sort those too!

Hi @joebien,

I’m glad that you’ve managed to fix the problem. Would you mind replying to your message in the article comments with your solution? It might be useful to others, and it will let them know that it wasn’t an error with the tutorial.

Thanks!

1 Like

Done

2 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.