Orkun Oz Orkun Oz - 7 months ago 42
Javascript Question

Error: [ng:areq] Argument 'angularJSCtrl' is not a function, got undefined

Can anyone tell me what's wrong with the code. Because I don't see anything missed. It was all working during the class. I'm quite new to javascript and angular.

I tried to check other threads with the same error but didn't help me to solve the issue.


<!DOCTYPE html>
<html ng-app="angularJS">
<script src="/bower_components/angular/angular.js"></script>
<script src="app.js"></script>
<script src="controller.js"></script>


{{"Type your name"}}

<div ng-controller="angularJSCtrl as kontrol">

<button ng-click ="kontrol.sayHello()"> Click here </button>
<input type="text" ng-model="kontrol.name">
<h3> All students list </h3>

<div ng-repeat="el in kontrol.studentObj">
<div ng-show="{{ el.age < 20 }}"> {{el}}</div>

{{ kontrol.price | currency}}
{{ kontrol.date | date}}



(function () {
.controller("angularJSCtrl", angularJSMethod);
.directive("directCtrl", directMethod);

function angularJSMethod(){
var vm = this;
vm.sayHello = sayHello;
vm.name = "Orkun";
vm.studentNames = ['John', 'Robbert', 'Adam'];
vm.studentObj = [{name: 'Orkun', age: 22}, {name: 'Bob', age: 18}];
vm.price = 2000;
vm.date = new Date();

function sayHello(){
alert("Welcome" + ' ' + vm.name)

function directMethod(){
return {
restrict: 'E',
templateUrl: 'custom.html'



(function () {
angular.module("angularJS", []);



Actually, the problem is that you don't need semicolon:

    .controller("angularJSCtrl", angularJSMethod); <--- here
    .directive("directCtrl", directMethod);

Remove it and everything will work fine