我有两个页面 - signup page
和login page
。我现在想要将两个表单集成到我的home page
上。我在HomepageModule.js
中添加了对两个控制器的引用,但注册功能不起作用。这是我的档案,我做错了什么?
Homepage.ejs:
<body ng-app="HomepageModule" ng-cloak>
<form ng-submit="submitLoginForm()" ng-controller="HomepageController">
<!-- Some Inputs -->
</form>
<div ng-controller="SignupController"
<form ng-submit="submitSignupForm()" id="sign-up-form" class="form-signin" name="signup">
<!-- Some Inputs -->
</form>
</div>
</body>
HomepageModule:
(function() {
'use strict';
angular.module('HomepageModule', ['toastr', 'compareTo','ngMaterial'])
.controller('HomepageController', function($scope) {
$scope.isOpen = false;
$scope.demo = {
isOpen: false,
count: 0,
selectedDirection: 'left'
};
})
.controller('SignupController', function($scope) {
$scope.isOpen = false;
$scope.demo = {
isOpen: false,
count: 0,
selectedDirection: 'left'
};
});
})();
HomepageController.js:
angular.module('HomepageModule').controller('HomepageController', ['$scope', '$http', 'toastr', function($scope, $http, toastr){
$scope.loginForm = {
loading: false
}
$scope.submitLoginForm = function (){
}
//other app logic
}]);
SignupController.js:
angular.module('HomepageModule').controller('SignupController', ['$scope', '$http', 'toastr', function($scope, $http, toastr){
// set-up loading state
$scope.signupForm = {
loading: false
}
$scope.submitSignupForm = function(){
}
//other app logic
}]);
编辑:
我最怀疑的地方是angular.module('HomepageModule').controller('SignupController', ...
行,是否应该从两个控制器中引用HomepageModule
?另外,在模块中包含两个控制器的语法是否正确?
答案 0 :(得分:0)
您需要以注册表单<form ng-submit="submitSignupForm()" ng-controller="SignupController" ...
答案 1 :(得分:0)
这将允许两个控制器存在。现在,页面上只存在HompageController。
<body ng-app="HomepageModule" ng-cloak>
<form ng-submit="HC.submitLoginForm()" ng-controller="HomepageController as HC">
<!-- Some Inputs -->
</form>
<form ng-submit="SC.submitSignupForm()" ng-controller="SingupController as SC" id="sign-up-form" class="form-signin" name="signup">
<!-- Some Inputs -->
</form>
</body>