angularjs - How can I handle angular-route with pure Node.js? -


i'm learning node.js without express.js (trying learn node.js itself). server side, got this:

node.js

// creating server var server = http.createserver(function(request, response) {     var filepath = false;      // send files each reqeust     if(request.url == '/') {         filepath = 'public/index.html';     }     else {         filepath = 'public' + request.url;     }      var abspath = './' + filepath;     sendfile(response, cache, abspath); // send response here }); 

and client side, used angular route (not ui-route).

angular.js:

app.config(function($routeprovider, $locationprovider) {     $routeprovider.when('/', {         templateurl: '/partials/foo.html', controller: 'fooctrl'     });      $routeprovider.when('/bar', {         templateurl: '/partials/bar.html'     });      $routeprovider.otherwise({redirectto: '/'});      $locationprovider.html5mode({         enabled: true,         requirebase: false     }); }); 

how can handle angular-route requests pure node.js? if use express.js, can done - want learn node.js first.

when call

#/bar 

it links

/partials/bar.html 

as per code.

in server, need put bar.html in

/public/partials/bar.html 

and should work magic


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -