AngularJS 未捕获的 ReferenceError : controller is not defined from module

标签 angularjs angularjs-routing

我有以下代码;

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', ...);

我收到以下错误
Uncaught ReferenceError: SomeControl is not defined from myApp

问题只是我不能使用 app.controller('SomeControl', ...) 语法吗?使用 $routeProvider 时?是唯一有效的语法:
function SomeControl(...)

最佳答案

使用引号:

            controller: 'SomeControl'

关于AngularJS 未捕获的 ReferenceError : controller is not defined from module,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17454782/

相关文章:

javascript - AngularJS - 需要 $routeChangeStart 和 $locationChangeStart 的某种组合

javascript - AngularJS 路由解析获取带有 id 的 $http 数据

javascript - AngularJS $http 返回 html 源代码

javascript - 如何同步延迟加载js脚本?

javascript - 如何注入(inject) $httpParamSerializer 以在 templateUrl 中使用

javascript - 如何在不刷新 Controller 的情况下替换 Angular 位置?

javascript - 是否可以使用 angularAMD 在运行时延迟加载 Angular 模块并将其注入(inject)到应用程序中?

javascript - 重新连接时客户端 SignalR 未收到消息

html - Angular Material FAB Speed Dial 在工具栏中有偏移

AngularJS 和 PhoneGap : $location. 路径导致后续 tempateUrl 查找失败