Diwesh Saxena Diwesh Saxena - 2 months ago 9
AngularJS Question

Angular argument is not a function: got undefined

I am trying a simple test code to check the Angular frontend, and running in this issue where it declares my function as undefined.

Here is my implementation:

EventDetails.html:

<!DOCTYPE html>
<html lang="en" ng-app="eventsApp">

<head>
<meta charset="UTF-8">
<title>Event Registration</title>
<link rel="stylesheet" href="/css/bootstrap.min.css"/>
<link rel="stylesheet" href="/css/app.css"/>

</head>

<body>
<div class="container">
<div ng-controller="EventController">
{{event.name}}
</div>
</div>

<script src="/lib/jquery.min.js"></script>
<script src="/lib/underscore-1.4.4.min.js"></script>
<script src="/lib/bootstrap.min.js"></script>
<script src="/lib/angular/angular.js"></script>
<script src="/js/app.js"></script>
<script src="/js/controllers/EventController.js"></script>

</body>

</html>


EventController.js

'use strict'

eventsApp.controller('EventController',
function EventController($scope) {
$scope.event = {
name: 'Angular Boot Camp',
date: '1/1/2013',
time: '10:30 am'
}
}
);


app.js

'use strict';

var eventsApp = angular.module('eventsApp', []);


web-server.js

var express = require('express');
var path = require('path');
var app = express();
var rootPath = path.normalize(__dirname + '/../');

app.use(express.static(rootPath + '/app'));

app.listen(8000);
console.log('Listening on port 8000.....');


I am running this on angualr version 1.4.0

Any help will be much appreciated

Error Code :

Google Chrome:

enter image description here

Firefox:

enter image description here

Directory Structure:

enter image description here

So looks like a 404 is there, but not sure why . Tried resetting browser clearing caches and things. But the directory structure is right

Answer

I think your problem is , invalid path of controller pls check that or you forgot that js file extension, you are given EventController instead of EventController.js