0

I am trying to add a new page to my website ( it was developed by somebody else ) and when I add another block to the route I just get an error like:

Error: [$injector:modulerr] Failed to instantiate module nameApp due to: [$injector:nomod] Module 'nameApp' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument. http://errors.angularjs.org/1.3.12/$injector/nomod?p0=nameApp

My routing config:

 .config(
        function($routeProvider, $locationProvider)
        {
            $routeProvider
                .when('/home', {
                templateUrl: 'templates/home.html',
                title: 'Home',
                controller: 'HomeController',
                reloadOnSearch: false
            })
            .when('/about', {
                templateUrl: 'templates/about.html',
                reloadOnSearch: false

            })
             .otherwise({ redirectTo: '/404' });
            $locationProvider.html5Mode(true);
        }
    )

I do not have any problems with this configuration as it loads ok in the Web Browser, but when I'm trying to add:

.when('/donate', {
    templateUrl: 'templates/donate.html',
    reloadOnSearch: false
    })

I receive the above error. ( I have also created the donate.html file )

index.html

<li>
    <a ng-class="getClass('/')" title="Home" href="/">Home</a>
</li>
<li>
    <a ng-class="getClass('/about')" title="About Us" href="/about">About Us</a>
</li>
<li>
    <a ng-class="getClass('/donate')" title="Donate" href="/donate">Donate</a>
</li>

Any help about what is this happening and how could I get rid of that error ? As a mention, when I receive that error, the webpage looks like a mess.

5
  • 1
    Where do you define nameApp? Commented Apr 23, 2015 at 7:56
  • 1
    In the same js file. The problem is when I add that new page. Otherwise the website is ok Commented Apr 23, 2015 at 7:59
  • 1
    Sounds like a syntax error that prevents Angular from creating the nameApp module. Commented Apr 23, 2015 at 8:01
  • 1
    There are no syntax errors as I double checked Commented Apr 23, 2015 at 8:05
  • Can you paste the non-working code? Commented Apr 23, 2015 at 8:19

1 Answer 1

1

I've got it done. This has nothing to do with angular but with nginx. Let's go deeper and tell you what happened:

I am using this flow in order to have my projects done: Ubuntu 12.04, nginx, PHP-FPM

Nginx has a sendfile directive, which defaults to on. It allows nginx to use the Linux kernel’s sendfile() operation to read the requested file from disk. This is typically quicker than using read() and write(). So far, so good.

The problem is that sendfile doesn’t work so well in virtual environments. The fix turned out to be insanely simple – just turn sendfile off. As it’s a development machine, the performance hit incurred by turning off this feature is pretty negligible. (It would want to be a pretty significant performance hit to outweigh the file truncation!) In the nginx config http server block, I added:

sendfile off;

Once nginx was restarted, I was getting served full static files, and all was well with the world again!

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

Comments

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.