2016-07-02 3 views
1

角度コントローラをインスタンス化できません:私はこれは私が持っているものであるセットアップに<code>AngularJS</code> と非常に基本的なログインfunctiniolityをしようとしています

<html> 
    <head> 
    <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> 

    </head> 
    <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" /> 
    <label>Password</label> 
    <input type="text" ng-model="password" /> 

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

    </body> 
    </html> 

ngLogin.js

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

しかし、私は、ログインボタンを何もクリックしません警告もコンソールログの何も起こらない、何が間違っている?

答えて

1

あなたのモジュールを登録する際に、依存関係の配列を渡します。

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.

+0

ありがとうは、働いていました。人は依存関係配列に合格しているに違いありません。 – Maven

+1

valar passulis - すべての男性が通過する必要があります –

1

ミッシング - []

angular.module("MyApp",[]) 
関連する問題