Maven Maven - 3 months ago 3x
AngularJS Question

Unable to instantiate Angular controller

I am trying to setup a very basic login functiniolity with


This is what I have:

<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Home Page - My ASP.NET Application</title>
<link href="/Content/site.css" rel="stylesheet"/>

<script src="/Scripts/angular.js"></script>

<body ng-app ="MyApp">
<script src="/Scripts/ng/ngLogin.js"></script>

<div id="loginBox" ng-controller="loginCtrl">
<form action="/" id="userLogin">
<label>User id</label>
<input type="text" ng-model="userId" />
<input type="text" ng-model="password" />

<input type="button" name="loginSubmit" ng-click="submit()" value="Login" />



angular.module("MyApp").controller('loginCtrl', ['$scope', '$log', function($scope, $log) {
$scope.submit = function () {
var usrName = $scope.userId;
var password = $scope.password;

But when I click the login button nothing happens neither the alert nor anything in the console log, what am I doing wrong?


Pass a dependencies array when you register your module:

angular.module("MyApp", [])

Error: [$injector:nomod] Module 'MyApp' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.