버전 1.1.5에서 최신 1.5.8로 angularJS를 마이그레이션하려고하는데이 오류가 발생합니다. :AngularJS 마이그레이션 from v1.1.5에서 v1.5.8 인수 'Login.Controller'는 정의되지 않은 함수입니다.
angular.js:13920 Error: [ng:areq] Argument 'Login.Controller' is not a function, got undefined http://errors.angularjs.org/1.5.8/ng/areq?p0=Login.Controller&p1=not%20a%20function%2C%20got%20undefined
JS
var app = {};
app = angular.module('myApp', ['ngResource', 'ngRoute'])
//Login Controller
Login = {
/**
* Initializes the login page.
*/
controller: function ($scope, $location, User) {
Login.initializeScopeVariables($scope);
Login.createScopeFunctions($scope, $location, User);
},
initializeScopeVariables: function ($scope) {
$scope.$root.forgotPasswordUsername = null;
},
createScopeFunctions: function ($scope, $location, User) {
$scope.reset = function() {
$scope.$root.filters = {};
Login.resetForm($scope);
}
$scope.submit = function() {
Login.submitForm($scope, $location, User);
}
$scope.validate = function() {
if ($scope.loginForm.$valid) {
$('#submit-btn').linkbutton('enable');
} else {
$('#submit-btn').linkbutton('disable');
}
}
$scope.$root.submitPasswordReminder = function() {
if ($scope.$root.forgotPasswordUsername) {
mask(true);
User.sendPasswordReminder($scope.$root.forgotPasswordUsername).success(
function (data) {
mask(false);
if (data.status == M2M.Response.ERROR) {
error(data.statusMessage);
} else {
info(Locale.get('passwordReminderSent'));
$scope.clearPasswordReminderForm();
}
}
).error(errorCallback);
}
}
$scope.$root.clearPasswordReminderForm = function() {
$('#forgot-password-window').window('close');
$scope.$root.forgotPasswordUsername = null;
}
$(document).keypress(function (event) {
if (13 == event.keyCode) {
$scope.submit();
$scope.$apply();
}
if (27 == event.keyCode) {
$scope.reset();
$scope.$apply();
}
})
},
/**
* Resets login form
*
* @param $scope
*/
resetForm: function ($scope) {
$scope.username = '';
$scope.password = '';
$('input').removeClass('validatebox-invalid');
},
/**
* Submits login form
*
* @param $scope
* @param $location
* @param User
*/
submitForm: function ($scope, $location, User) {
if (!($scope.username && $scope.password)) {
return;
}
mask(true);
User.authenticate($scope.username, $scope.password).success(
function (data) {
if (data.status == M2M.Response.ERROR) {
mask(false);
error(data.statusMessage);
} else {
location.href = 'main.html';
}
}
).error(errorCallback);
}
}
HTML
<div class="login-area" ng-controller="Login.controller" style="width: 1300px; margin: auto">
<form autocomplete="off">
<div class="login-panel" ng-form name="loginForm" align="center">
<table>
<tr>
<td><fmt:message key="username"/></td>
<td>
<input class="easyui-validatebox w140" type="text" name="username"
data-options="required:true"
ng-model="username"
ng-change="validate()"
required/>
</td>
</tr>
<tr>
<td><fmt:message key="password"/></td>
<td><input class="easyui-validatebox w140" type="password" name="password"
data-options="required:true"
ng-model="password"
autocomplete="off"
ng-change="validate()"
required/></td>
</tr>
<tr>
<td colspan="2">
<a id="submit-btn" class="easyui-linkbutton" data-options="iconCls:'icon-ok',disabled: true"
ng-click="submit()"><fmt:message key="submit"/></a>
<a id="reset-btn" class="easyui-linkbutton" data-options="iconCls:'icon-undo'"
ng-click="reset()"><fmt:message key="reset"/></a></td>
</tr>
</table>
<div class="clr tac small">
<a href="#" id="forgot-passwd" onclick="$('#forgot-password-window').window('open')"><fmt:message
key="login.forgotPassword"/></a>
</div>
<br>
<div class="clr tac">
<fmt:message key="login.disclaimer"/>
</div>
</div>
</form>
</div>
각도의 최신 버전에서 이것이 왜 발생하는지 알 수 없습니다.
코드를 변경해야합니까?
여기서'app.controller'를 수행하는 부분은 어디입니까 –
Dudette! 귀하의 로그인 컨트롤러는 어디입니까 ?? 당신은'app.controller ("loginCtrl", .., function() {}); –
그래, 나도 전에도 이런 걸 본 적이 없지만 그 코드는 괜찮 았어. 'Login = { 컨트롤러 : function ($ scope, $ location, User) {...} ' – Margaret