Search code examples
angularjsroutesdirectory-structure

Two separate angularJS apps on the same file system


My routes will look something like this:

/create-company/index.html#/part-one
/dashboard/index.html#/view1
/auth/

Now the create-company app is used initially and from then on the branch dashboard app is used.

Currently I use the seed project to make app, config, logs, scripts & test folders in my home directory for one app.

To add the second app, Should I create two folders app1 & app2 which each contain their own app, config, logs, scripts & test folders?

Then I can point /dashboard/ to /app1/app and point /create-company/ to /app2/app

Or would it be better to stick with a single angularJS app at /app/ and to point both /create-company/ and /dashboard/ to the same /app/ folder?


Solution

  • Although there may be use-cases where having multiple, completely separated apps is helpful and/or appropriate, from your description the two 'apps' you describe would appear to be different sub-sections of one larger app.

    Consider in your usage, would there be any overlapping components, such as shared directives, templates, or services? If so, it would be best to avoid duplication.

    In addition, there is no restriction on loading the same app on two different pages, with different markup - controllers etc, which would lead to completely different functionality.

    For example the following is perfectly fine on different pages:

    <body>
        <div ng-app="my-app">
            <div ng-controller="createCompany">
                <!-- Section specific content here, directives etc -->
            </div>
        </div>
    </body>
    
    <body>
        <div ng-app="my-app">
            <div ng-controller="dashboard">
                <!-- Section specific content here, directives etc -->
            </div>
        </div>
    </body>