Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am facing a strange problem with my angularjs project.

I have a website like - www.server.com/pwm (home page). In the page there is an anchor tag with takes me to another page - www.server.com/publishers. When I load the home page and navigate to the publishers page by clicking the anchor tag, everything works fine. But when I directly type the url in the browser I get the below exceptions (eg. If I load the home page www.server.com/pwm and then type "/publishers" at the end of the url)

[$injector:nomod] Module 'ui.bootstrap' 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.2.18/$injector/nomod?p0=ui.bootstrap"

The confusing part is that I have included the necessary libraries and it works fine when I navigate through the webpage. The problem occurs when I try to directly navigate to a child page. I am making use to ngRoute and templates to load the page

var pubsApp = angular.module('pubsApp', ['ngResource', 'ngRoute', 'ui.bootstrap'])

and my script files

<script src="/Scripts/jquery-1.9.1.js" type="text/javascript"></script>
<script src="/Scripts/angular.js" type="text/javascript"></script>
<script src="/Scripts/angular-route.js" type="text/javascript"></script>
<script src="/Scripts/angular-sanitize.js" type="text/javascript"></script>
<script src="/Scripts/angular-resource.js" type="text/javascript"></script>
<script src="/Scripts/bootstrap.js" type="text/javascript"></script>
<script src="Scripts/angular-ui/ui-bootstrap.min.js" type="text/javascript"></script>
<script src="Scripts/angular-ui/ui-bootstrap-tpls.min.js" type="text/javascript"></script>
<script src="/js/app.js" type="text/javascript"></script>
share|improve this question
    
Is this a single page app? If so, what does your routing table look like? –  drew_w Jun 23 at 12:33
    
im not familiar with angular for bootstrap, but dont you include both, angular and jquery as well as both of their respective bootstrap.js files? Id suppose to leave out at least /Scripts/bootstrap.js... –  nozzleman Jun 23 at 12:37
2  
The src for ui-bootstrap's js files is relative so there really is no wonder why it doesn't work. Make them absolute like the rest? –  ivarni Jun 23 at 12:41
1  
you don't need ui-bootstrap.min.js and ui-bootstrap-tpls.min.js. ui-bootstrap-tpls.min.js contains all code and the templates. –  maklemenz Jun 23 at 13:11
add comment

2 Answers 2

up vote 0 down vote accepted

All of your script tags are using absolute paths (they start with a /) except for the angular-bootstrap tags; they use relative paths. That means they are relative to wherever you are in the browser.

Your javascript files are all located at www.website.com/Scripts/... because all of your script tags except those two use absolute paths, they will always look for the script in the same place. However, the two angulcar-bootstrap paths will look in different place depending on where you are in the browser.

The reason it works unless you go directly to the child page is because angular only loads javascript files on the initial page load and not on navigation.

So simply change your angular-bootstrap script tags to use absolute paths like the rest of your script tags.

share|improve this answer
    
This is really a good point. I will check making these changes. Thanks a lot –  user1737036 Jun 23 at 23:02
add comment

I guess, it has nothing do with ui-bootstrap. This issue is related to angular routing. Please try this server.com/#/publishers (When writing location at address-bar manually).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.