AngularJS 控制器无法在 IntelliJ 中使用 ngRoute(Web 服务器问题?)
AngularJS Controller is not working with ngRoute in IntelliJ (Web server issue?)
我正在使用 ngRoute 制作一个基本应用程序。路由正常,但我的控制器内的范围元素未显示在 html.
中
<p>{{ message }}</p> <!-- Nothing shows -->
<p>{{ message }}X</p> <!-- 'X' shows -->
Angular,主要html.
中引用了路由、应用程序和注册脚本
<body>
<div class="page">
<main class="cf" ng-view></main>
</div>
</body>
app.js
var myApp = angular.module('myApp', ['ngRoute']);
myApp.config(['$routeProvider', function($routeProvider) {
$routeProvider
.when('/login', {
templateUrl: 'views/login.html',
contoller: 'RegistrationController'
})
.when('/register', {
templateUrl: 'views/register.html',
contoller: 'RegistrationController'
})
.otherwise({
redirectTo: '/login'
});
}]);
registration.js
myApp.controller('RegistrationController', ['$scope', function ($scope) {
$scope.message = "Welcome to my App!";
}]);
login.html
<section class="card login">
<form name="myform"
novalidate>
<div class="textintro">
<h1>Hi there!</h1>
<p>Log-in to access the awesomeness!</p>
<p>{{ message }}</p>
</div>
<fieldset>
<input type="email" name="email" placeholder="Email">
<input type="password" name="password" placeholder="Password">
</fieldset>
<button type="submit" class="btn">Login</button>
<p>or <a href="#/register">register</a></p>
</form>
</section>
打错了:
contoller: 'RegistrationController'
应该是:
controller: 'RegistrationController'
我正在使用 ngRoute 制作一个基本应用程序。路由正常,但我的控制器内的范围元素未显示在 html.
中<p>{{ message }}</p> <!-- Nothing shows -->
<p>{{ message }}X</p> <!-- 'X' shows -->
Angular,主要html.
中引用了路由、应用程序和注册脚本<body>
<div class="page">
<main class="cf" ng-view></main>
</div>
</body>
app.js
var myApp = angular.module('myApp', ['ngRoute']);
myApp.config(['$routeProvider', function($routeProvider) {
$routeProvider
.when('/login', {
templateUrl: 'views/login.html',
contoller: 'RegistrationController'
})
.when('/register', {
templateUrl: 'views/register.html',
contoller: 'RegistrationController'
})
.otherwise({
redirectTo: '/login'
});
}]);
registration.js
myApp.controller('RegistrationController', ['$scope', function ($scope) {
$scope.message = "Welcome to my App!";
}]);
login.html
<section class="card login">
<form name="myform"
novalidate>
<div class="textintro">
<h1>Hi there!</h1>
<p>Log-in to access the awesomeness!</p>
<p>{{ message }}</p>
</div>
<fieldset>
<input type="email" name="email" placeholder="Email">
<input type="password" name="password" placeholder="Password">
</fieldset>
<button type="submit" class="btn">Login</button>
<p>or <a href="#/register">register</a></p>
</form>
</section>
打错了:
contoller: 'RegistrationController'
应该是:
controller: 'RegistrationController'