usrlog usrlog - 2 years ago 56
AngularJS Question

Argument (Controller) is not a function, got undefined

After googling for an hour and searching in Stackoverflow I cannot get the answer. I am new to angular and this is just a practice but i cannot make it work. I get this error in the console:

Error: Argument 'StoreController as store' is not a function, got

The code:

<!DOCTYPE html>
<html ng-app="myApp">

<div ng-controller="StoreController as store">

<script type="text/javascript"
<script type="text/javascript"

app.js file:

(function() {
var app = angular.module('myApp', []);

app.controller('StoreController', function() {
this.employee = {
name: 'John',
age: 32


Answer Source

Your Angular version is outdated. You're currently using 1.0.7. The controllerAs construct was only added in version 1.2. You should up your version to the latest.

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