2017-01-29 4 views
1

コントローラと部分ビューを分離する方法を学ぶためにログイン/サインアップサイトを作成しようとしていますが、なぜ私の 'LoginController'が注入されていないのか分かりません。他のフィードバックをお寄せください。AngularJSコントローラが部分的にロードされない

app.js

angular.module('Registration', ['ngRoute']) 
.config(['$routeProvider', ($routeProvider) => { 
    $routeProvider 
    .when('/login', { 
     templateUrl: 'app/login/login.html', 
     controller: 'LoginController' 
    }) 
    .otherwise({ redirectTo: '/login' }); 
}]); 

LoginController.js

angular.module('Registration') 
.controller('LoginController', ['$scope', ($scope) => { 
    $scope.message = 'Does this work?'; 
}]); 

login.htmlと

<div class="col-md-offset-3 col-md-6"> 
{{ message }} 
</div> 

index.htmlを

<!doctype html> 
<html ng-app="Registration"> 
<head> 
    <meta charset="utf-8"> 
    <meta http-equiv="X-UA-Compatible" content="IE=edge"> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <title>Sup?</title> 
    <link rel="stylesheet" type="text/css" href="assets/css/bootstrap.min.css"> 
    <link rel="stylesheet" type="text/css" href="assets/css/styles.css"> 
</head> 
<body> 
    <div class="container"> 
    <div class="row"> 
     <div ng-view></div> 
    </div> 
    </div> 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> 
    <script src="assets/js/bootstrap.min.js"></script> 
    <script src="assets/js/angular.min.js"></script> 
    <script src="assets/js/angular-route.min.js"></script> 
    <script src="app/app.js"></script> 
    <script src="app/login/LoginController.js"></script> 
</body> 
</html> 

server.js

var express = require('express'); 
var app = express(); 

app.use(express.static('./public')); 

app.listen(3000,() => { 
    console.log('Listening on port 3000.'); 
}); 

Directory Structure

+0

を使用すると、/ログインに移動したときに、コンソールには何を見ていますか? –

+0

TypeError:Function.prototype.bind.apply(...)はコンストラクタではありません – jgallardo

答えて

関連する問題