0

I'm building a simple Angular app for a demo for a client. They don't know much about web server technology so I was trying to set it up as a stand along app that will run in there browser. I wanted to use ngRoutes to break my code up into templates but I can't seem to get it to work with any stand alone server (like live-server or nodemon).

Anyhow can I do this without a server or is it not possible. From what I can tell it won't work with anything I try.

Here is my route code.

 angular.module("myApp", ['ngRoute','ui.bootstrap','ui-leaflet'])
.config(function($routeProvider,$locationProvider){
    $routeProvider
        .when('/search',{
            controller: 'searchCtrl',
            templateUrl: '/views/search.html'
        })
        .when('/list',{
            controller: 'listCtrl',
            templateUrl: '/views/list.html'
        })
        .otherwise({
            redirectTo: '/search'
        });
        $locationProvider.html5Mode(true);
    });
Showcaselfloyd
  • 790
  • 7
  • 28
  • "stand *alone* app". That will run in *"their"* browser. And why *not* use Express - even if it *is* only to "run in their browser"??? – paulsm4 May 31 '16 at 19:34
  • I was under the impression they would need node installed on their machine. Am I incorrect? – Showcaselfloyd May 31 '16 at 19:42
  • So you don't only want to eliminate Express: you want to run without NodeJS, too. The answer is "maybe". Look here: http://stackoverflow.com/questions/26398537/do-i-need-node-js-to-use-angularjs. My strong feeling, however - if you *can* install NodeJS, you probably should. My distro, for example, is only about 34MB (plus whatever NPM modules I've downloaded in different directories). – paulsm4 May 31 '16 at 20:21

1 Answers1

1

OK, Let me clarify something Nodemon itself is NOT a server at all, nodemon is a plugin which Monitor's for any changes in your node.js application and automatically restart the server. you will need to install the server on their local machine I suppose they are running the application locally and if you want to run the server by itself all you have to do is to add it to startup. and It will run automatically.

Wcan
  • 840
  • 1
  • 10
  • 31
  • Okay, but is that assuming they have node already on their PC. What id they do not. Also how would I add Nodemon to a startup file? – Showcaselfloyd May 31 '16 at 19:41
  • Ok, if they have not installed node already on their local machine, just download it from here https://nodejs.org/en/ and insall it, once you have done the installation part you can go here and understand how to run node as a windows service. http://stackoverflow.com/questions/10547974/how-to-install-node-js-as-windows-service – Wcan May 31 '16 at 20:01
  • also you can use some third party plugin available on github for instace "forever" http://stackoverflow.com/questions/14251451/using-forever-module-for-windows-in-nodejs – Wcan May 31 '16 at 20:02
  • this is probably the easiest one. http://stackoverflow.com/a/12949606/4578345. but there are more reliable ways such as running node as service. – Wcan May 31 '16 at 20:03
  • okay, but the short answer is I can't use routes without running a some sort of server then correct? – Showcaselfloyd May 31 '16 at 20:34
  • what is it you are using for backend – Wcan May 31 '16 at 20:36
  • No backend. It's just a demo of Angular for a client. They want me to send them the files, so I have no idea what they have or even if they no how to run a server of any sort. So again can it be done? – Showcaselfloyd May 31 '16 at 20:37
  • 1
    dude if you don't have back-end you don't need node server you can run angular without server, yes it is going to work as long as appropriate files and the dependencies files are there. – Wcan May 31 '16 at 20:39
  • Okay, that's what I thought. I must be doing something wrong with my code then. Basically I was just trying to get the routing to work. Which so far has not been happening. Thanks – Showcaselfloyd May 31 '16 at 21:13
  • did you define your controller ? because the code above is fine, I don't see any error in it. – Wcan May 31 '16 at 21:16
  • Yes, my controller is in a separate file. I'll post it when I get home. I think it's my directory structure is messed up. I have all my files serving or of /public – Showcaselfloyd May 31 '16 at 21:17
  • That's thing I was just getting a bunch of 404 errors. I'm going to try this with out the /public and make it all in one directory. Seems sloppy but I'm guessing this will fix my issues. – Showcaselfloyd May 31 '16 at 22:56
  • well sure, try it, I couldn't fix it you are welcome to ask anything. – Wcan May 31 '16 at 22:58
  • Okay, so it still doesn't work. I've got all my bower_components and html pages in the same dir and it still won't work. Here's my latest error GET http://127.0.0.1:4000/lib/bower_components/bootstrap/dist/css/bootstrap.min.css (index):18 GET http://127.0.0.1:4000/lib/bower_components/angular/angular.min.js (index):19 GET http://127.0.0.1:4000/lib/bower_components/angular-route/angular-route.min.js – Showcaselfloyd May 31 '16 at 23:10
  • Okay I think it may have something to do with this stupid like of HTML . – Showcaselfloyd May 31 '16 at 23:17
  • More weirdness. I sort of have something working now, but it will only work for the .otherwise() clause. If I try typing anything into the URL I get this. Cannot GET /list – Showcaselfloyd May 31 '16 at 23:23
  • do you know how to make plunker ? If you make it i'll take a look it looks like sort of baseurl problem to me, but i cannot say anything for sure unless i take a look at ur code – Wcan Jun 01 '16 at 01:32
  • Understood. I'm not going to have time tonight to recreate it. Perhaps tomorrow. Thanks – Showcaselfloyd Jun 01 '16 at 01:33