Join the Stack Overflow Community
Stack Overflow is a community of 6.7 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

I'm trying to use Angular module in nodeJS Application with express 4 and jade.

So, for it i did npm install angular --save and var angular = require('angular'); in app.js.

But It's Throwing an Error

e:\Project\node_modules\angular\angular.js:29016
})(window, document);
   ^
ReferenceError: window is not defined
    at Object.<anonymous> (e:\Project\node_modules\angular\angular.js:29016:4)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (e:\Project\node_modules\angular\index.js:1:63)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (e:\Project\app.js:11:15)
    at Module._compile (module.js:456:26)

In Reason for this.

I'm going to set active status to my sidebar in anjularjs. Here My Jade File

ul.sidebar-nav(ng-controller="HeaderController")
    // li.sidebar-brand
    li(ng-class="{ active: isActive('/dashboard')}")
        a(href='/dashboard') Dashboard
    li(ng-class="{ active: isActive('/cases')}")
        a(href='/cases') Cases
    li(ng-class="{ active: isActive('/contacts')}")
        a(href='/contacts') Contacts
    li(ng-class="{ active: isActive('/documents')}")
        a(href='/documents') Documents
    li(ng-class="{ active: isActive('/calendar')}")
        a(href='/calendar') Calendar
    li(ng-class="{ active: isActive('/timeline')}")
        a(href='/timeline') Timeline

and here module

function HeaderController($scope, $location) 
{ 
    $scope.isActive = function (viewLocation) { 
        return viewLocation === $location.path();
    };
}
share|improve this question
1  
What do you expect angular to do, server side, in a node.js application? – Quentin Dec 23 '15 at 10:15
    
Your edits don't seem to have anything to do with what I asked in my comment. One bit of the code you added appears to be some server side code to generate HTML with angular expando-attributes that will be sent to the browser. The other appears to be some code to run client side in the browser. – Quentin Dec 23 '15 at 10:28
up vote 1 down vote accepted

In nodejs enviroment there is no window object. There is an "equivalent" for window. Here you can read about it DOC for Global. Angular is for client side development. You are not able to run it on server side.

share|improve this answer
    
agree with you, I got some idea from your comment. Thadam – DININDU Dec 23 '15 at 10:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.