asp.net mvc angularjs controller throwing error on registration

时间:2015-10-30 23:48:48

标签: javascript angularjs asp.net-mvc-4 controller

I have a simple view: @{ ViewBag.Title = "Arbitrary Title"; Layout = "~/Views/Shared/_Layout.cshtml"; } <div ng-controller="MyController as myCtrl"> <div id="grid" kendo-grid k-options="myCtrl.Options"></div> </div> with the accompanied controller: (function () { "use strict"; /***Debugger throws exception here***/ angular.module("myApp").controller("MyController", MyController); MyController.$inject = ['$scope']; function MyController($scope) { //for brevity } })(); The console throws the exception: Error: [ng:areq] Argument 'MyController' is not a function, got undefined http://errors.angularjs.org/1.4.0/ng/... I'm fairly new to angular, but from what I have learned, it looks like i'm not registering the controller correctly? Other controllers in the project i'm working on are registered the same way, so i'm a bit lost. The _Layout.cshtml shared view has the ng-app="myApp" set as well.

0 个答案:

没有答案