Abhishek Parikh Abhishek Parikh - 1 year ago 143
AngularJS Question

Angular JS error angular.js:38Uncaught Error: [$injector:modulerr]

While loading my index.html i am facing this error


<script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.2.7/angular.min.js" ></script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope,$http) {
$scope.submit= function(){
var data = {
book: {
author: $scope.author,
title : $scope.title,
body : $scope.body

$http.post("/", data).success(function(data, status) {
console.log('Data posted successfully');

<body ng-app="myApp">
<div ng-controller="myCtrl">
<input type="text" ng-model="author">
<br> Title:
<input type="text" ng-model="title">
<br> Body:
<input type="author" ng-model="body">
<input type="submit" value="Submit" ng-click="submit()">

I am running it on my node.js code which is


var express = require('express');
var bodyParser = require('body-parser');
var app = express();
var path = require('path');

app.use(express.static(__dirname + './public'));
app.use(express.static(path.join(__dirname, 'public')));
app.use(bodyParser.urlencoded({ extended: true }));

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

app.post('/', function(req,res){
res.sendFile(__dirname +'/index1.html');

console.log('server running at 3000!')

I am getting index.html correctly but in google chrome inspection it is showing me error

angular.js:38Uncaught Error: [$injector:modulerr]

Answer Source

Your code is working fine in our machines.

As you said in one comment that you are getting the old files always, it should be cache problem

If it is the cache problem, steps to clear cache in chrome.

1) Open Chrome.
2) On your browser toolbar, tap More .
3) Tap History, and then tap Clear browsing data.
4) Under "Clear browsing data," select the checkboxes for Cookies and site data and Cached images and files.
5) Use the menu at the top to select the amount of data that you want to delete. ...
6) Tap Clear browsing data.

If you want to remove cached views from the code.

app.run(function($rootScope, $templateCache) {
    $rootScope.$on('$routeChangeStart', function(event, next, current) {
        if (typeof(current) !== 'undefined'){

Here is a link where you get these sort of answers.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download