我有兩頁 - 一個signup page
和login page
。我現在想要將這兩個表格整合到我的home page
上。我在我的HomepageModule.js
中添加了對兩個控制器的引用,但註冊功能不起作用。這裏是我的文件,我做錯了什麼?無法讓第二個控制器在Angular SPA上工作
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
?此外,在模塊中包含兩個控制器的語法是否正確?
對不起,這是一個錯字,請看現在。 –
可能在SignupController.js中使用'Angular'而不是'angular'來代替它的問題 – kmalek
當它們都是小寫字母時,它的效果是一樣的...... –