AngularJS Uncaught ReferenceError: controller is not defined from module

Joshua Wooward picture Joshua Wooward · Jul 3, 2013 · Viewed 34.8k times · Source

I have the following code;

var app =
    angular.
        module("myApp",[]).
        config(function($routeProvider, $locationProvider) {
            $routeProvider.when('/someplace', {
                templateUrl: 'sometemplate.html',
                controller: SomeControl
             });
             // configure html5 to get links working on jsfiddle
             $locationProvider.html5Mode(true);
        });

app.controller('SomeControl', ...);

I get the following error

Uncaught ReferenceError: SomeControl is not defined from myApp

Is the problem just that I can not use app.controller('SomeControl', ...) syntax? when using $routeProvider? is the only working syntax:

function SomeControl(...)

Answer

Foo L picture Foo L · Jul 3, 2013

Use quotes:

            controller: 'SomeControl'