1

i am using atom ide for running the following angular code

<!DOCTYPE html>
<html ng-app="home">
<head>
<title></title>
<meta charset="utf-8" />
 <script src = 
     "https://ajax.googleapis.com/ajax/libs/angularjs/1.3.3/angular.min.js">
 </script>
<script src ="/controller/sample.js"></script>
<link 
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" 
rel="stylesheet">
</head>
<body class="container" ng-controller="designController">
<br/>
<br />
<br />
<div class="row" style="background-color:purple;">
 <font color="white">ellucian University</font>
 </div>
<br/>
<br/>
</body>
</html>

i have another controller sample.js

angular.module('home',[]).controller('designController',function($scope){
$scope.message = "hii";
});

and i have another app.js file to run the server

var express = require('express');
var path    = require("path");
var app= express();

app.get('/',function(req,res){
res.sendFile(path.join(__dirname+'/index.html'));
});
app.listen(3000);
console.log('you are listening to a port 3000');

whenever i run my app.js file i am getting an index.html page but angular is not working in index.html file i am new to nodejs so please help me out. Thanks in advance

8
  • What is not working? the js file not loaded? do you see any error in the network tab or console? Commented Apr 3, 2017 at 6:14
  • Uncaught Error: [$injector:modulerr] errors.angularjs.org/1.3.3/$injector/……ogleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.3.3%2Fangular.min.js%3A18%3A179) Commented Apr 3, 2017 at 6:21
  • This is the error i am getting in a network console tab Commented Apr 3, 2017 at 6:22
  • Don't use the minified version of angular during development: that will allow you to get more helpful error messages. Ad don't use version 1.3.3. The current version is 1.6.x. But anyway, if your web server only serves your index.html, and doesn't serve your JS files, there's no way they can be loaded by the browser. Commented Apr 3, 2017 at 6:46
  • Maybe index.html is not able to include sample.js properly. Try adding app.use('/controller', express.static(__dirname + '/path/to/controller/folder/')); before you server index.html. Commented Apr 3, 2017 at 7:02

0

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.