Search code examples
angularjslocalangular-bootstrap

Can't get a simple angular-bootstrap example running on local machine


I'm not able to run a simple angular-bootstrap example. It runs well on Plunkr or on JSFiddle, but NOT locally on my machine. It's about a tab bar, so I use

<uib-tabset>
    <uib-tab>
       ...
    </uib-tab>
</uib-tabset>

See this jsfiddle and this Plunker examples (both contain same code). They work like intended, showing me a tab bar with 3 tabs. Do I now put this code into a html file on my system and runs it locally, the following happens:

result_in_firefox

What is the reason behind this? The firefox console (F12) is empty, so there should be no error. Why can't I run my site locally? Do I need an extra server like tomcat for this? If yes, why? I just want to test something out real quick, I don't want to get a server only for this, except when it really is necessary...

PS: Note that these first steps actually worked! http://www.w3schools.com/angular/ But as soon as wanted to try out a tab bar, it keeps failing.


Solution

  • As you are referencing the external resources with // (e.g. //ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js), you are not specifyng the protocol.

    So when you access your file locally, it will keep the file:// protocol (e.g. file://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js) and this resources are obviously not available.

    To solve the issue, you could use one of this methods: