Organizational Research By

Surprising Reserch Topic

angularnode app ignores routing and doesnt load view into ng view


angularnode app ignores routing and doesnt load view into ng view  using -'javascript,html,angularjs,node.js,routing'

I am developing a Node+Angular application. I am familiar with Angular, but a beginner in Node so I figured it would be a great start. I am not sure if the problem is with Node or with Angular, so I will just post the code here.

My folder hierarchy is:

- public
  - AppAngular
    - controllers
        chatController.js
    - models
    - views
        chatView.html
    app.js
index.html
server.js


In my server.js, I've specified the code below:

app.get('*', function (req, res) {
    res.sendFile(__dirname + '/index.html')
})


I don't have any API, since the plan is to build a real-time chat with Socket.io, something I've always wanted to try out.

Anyway, my app.js looks like this:

var app = angular.module('ChatApp', ["ngResource"])

app.config(['$routeProvider', '$locationProvider',
    function ($routeProvider, $locationProvider) {
        $locationProvider.html5Mode(true);

        $routeProvider
            .when('/', {
                templateUrl: 'views/chatView.html',
                controller: 'chatController'
            })
            .otherwise({
                redirectTo: '/'
            })
}])


I have referenced everything in my index.html like this:

<!DOCTYPE html>
<html ng-app="ChatApp" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title>Chat</title>

    <script src="/node_modules/angular/angular.js"></script>
    <script src="/node_modules/angular/angular-resource.js"></script>
    <script src="/public/AppAngular/controllers/chatController.js"></script>
    <script src="/public/AppAngular/app.js"></script>

    <script src="/socket.io/socket.io.js"></script>
    <script>
        var socket = io();
    </script>
</head>
<body>
    <div ng-view></div>
</body>
</html>


There is no need to post contents of chatView.html and chatController.js since both are straightforward.

Does anyone have the slightest idea to what's the problem? I have a pretty similar config in one of my other projects, with dozens of routes and it works flawlessly but this... Meh. Thank you, in advance.
    
asked Oct 11, 2015 by patelnikul321
0 votes
2 views



Related Hot Questions



Government Jobs Opening


...