0

I would like to get some advice on the correct structure of my AngularJS app.

This is the current structure of my project within the root directory:

enter image description here

As you can see, my index.html is inside a sub-directory www.

The problem is that when I deploy my app to my server, the www is included in the URL so that my URLs look like this: www.myWebsite.com/www/home instead of like this: www.myWebsite.com/home.

I've seen several projects with the same structure (where index.html is not within the root directory) but not having the same issue with the URLs.

Any help would be great appreciated. Thanks!

5
  • It really depends on how your project is structured. Usually angular projects generate a "bundle" (a kind of binary), and that bundle is what is deployed to the server. If this is the case, it doesn't matter much where your index.html is, what actually matters is where your "bundler" places the index.html in the bundle and where you place your bundle at the server. Commented Jun 16, 2017 at 21:52
  • @acdcjunior Is this bundle automatically generated or is a configuration required? Because right now I just upload my raw files to the server. And how do I know where this bundle is placed at the server? Commented Jun 16, 2017 at 21:58
  • I think if you were using bundles, you would know. So, your deployment procedure is just placing the whole project folder at the server? Apart from the URL, does it work perfectly? Commented Jun 16, 2017 at 22:18
  • @acdcjunior Yes, I sort of just copy and paste all the files at the server. The only other problem that I have noticed is that all the directive templates that I referenced using templateUrl are also not retrieved. But apart from that everything else is working fine. I can navigate the website and see contents. Commented Jun 16, 2017 at 22:32
  • During development, how do you do it? Do the directives work then? Commented Jun 17, 2017 at 0:29

2 Answers 2

1

If you want a standard: How about using Angular CLI? After you install it run ng new myapp and then you will have a standard Angular application in the myapp directory.

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

2 Comments

I am using Angular 1.6. Does Angular CLI work with this version of Angular?
I do not think so. There are completely different sites (and stackoverflow tags) for AngularJS and Angular 2~. If you want the Angular JS folks to have a look you may want to update your questions tags.
0

There are many ways that you could handle this. And it really depends on your workflow. I would tell you that when you deploy your application into a live environment that you would only need to deploy the www subdirectory.

It also looks like you're using your own build process with gulp rather than the common tool, the Angular CLI, which I would advise you looking it. The bundle/dist folder it will produce for you will have everything built and working for you (which should address the issue with the directives you have).

You did mention though that you're just copying and pasting files into a server... Do you mind me asking what your deploy environment is like?

1 Comment

I am not sure how you want me to describe the deploy environment but I am trying to deploy my website to a hosting website called x10hosting.com. I use FileZilla to transfer my files to the server.

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.