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.

8
  • 1
    No. angular-js only works in the browser because it manipulates the DOM. node.js is a server-side JavaScript implementation with I/O functionality. Commented Oct 21, 2014 at 6:36
  • So it has to do something with the local development and the way I am doing my url? Commented Oct 21, 2014 at 6:38
  • Read the tutorials on the website. Commented Oct 21, 2014 at 6:39
  • I have read the tutorials but they mostly use it with a node app. So it still looks different and I cannot work out the kinks. Commented Oct 21, 2014 at 6:42
  • i am using visual-studio to run/develop angular app and it works fine. I have hosted using IIS and am not using node. Commented Oct 21, 2014 at 6:45

1 Answer 1

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.

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

2 Comments

Okay yea I had that idea what about the ui.routing any idea on how that works?
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.

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.