0

Do i need to host my angular application on a node server for it to work? I have been doing local development and am trying to integrate ui.router into my application but it does not seem to work because of the root/file/file/index.html file directory when running in the browser. Is that what is causing it or is it that I need to utilize these tools with a NodeJS server for them to cooperate.

Here is what I am doing with the ui.router

      var app = angular.module("myapp",[
         'ui.router'
      ]).config(function($stateProvider, $urlRouterProvider){
      $stateProvider.state('login',{
         url:'/login',
         templateUrl:'views/login.html'
      });

Solved the problem by just running the application on my server which resolved the ui.router problem.

inoabrian
  • 3,685
  • 1
  • 17
  • 26

1 Answers1

4

You will need a server to run your Angular app, not necessarily a node server.

From https://docs.angularjs.org/tutorial/ :

While Angular applications are purely client-side code, and it is possible to open them in a web browser directly from the file system, it is better to serve them from a HTTP web server. In particular, for security reasons, most modern browsers will not allow JavaScript to make server requests if the page is loaded directly from the file system.

Aniket Sinha
  • 5,716
  • 6
  • 34
  • 49
  • Okay yea I had that idea what about the ui.routing any idea on how that works? – inoabrian Oct 21 '14 at 06:40
  • 1
    UI Routing will work as it is supposed to be. You just need to run your index.html file using server (not opening via a browser). If all your routing are wired correctly, then they should work as usual. – Aniket Sinha Oct 21 '14 at 06:42