Having an issue with my second controller (RegisterController) in the module I've created. The first one is working perfectly fine. I have both controllers in a file named user.js
var app = angular.module("User", []);
app.controller('LoginController', ['$scope', '$http',
function($scope, $http) {
$scope.user = {
email: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b1d3d3d3f1d2d2d29fd2dedc">[email protected]</a>',
password: '',
username: 'sex',
};
$scope.login = function() {
return $http.post('http://localhost/cw/index.php/rest/resource/user/action/login', $scope.user).then(function successCallback(response) {
if (response.data.success == 'true') {
}
}, function errorCallback(response) {
});;
}
}
]);
app.controller('RegisterController', ['$scope', '$http',
function($scope, $http) {
$scope.user = {
email: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="05646766453437362b666a68">[email protected]</a>',
password1: 'lol',
password2: '',
username: 'blah',
profile_picture: '',
dobDay: '',
dobMonth: '',
dobYear: '',
};
$scope.submit = function() {
alert("submit");
}
}
]);
<table>
<tr>
<td>
<span>
<table style="text-align: right" ng-app="User" ng-controller="LoginController">
<tr>
<td>
Email
</td>
<td>
<input type="text" ng-bind="user.email" ng-model="user.email">
</td>
</tr>
<tr>
<td>
Password
</td>
<td>
<input type="password" ng-bind="user.password" ng-model="user.password">
</td>
</tr>
<tr>
<td></td>
<td style="float:left">
<button ng-click="login()">login</button>
</td>
</tr>
</table>
</span>
</td>
<td>
<div style="border-left:1px solid">
<table style="text-align: left" ng-app="User" ng-controller="RegisterController">
<tr>
<td>
Username
</td>
<td>
<input type="text" ng-bind="user.username" ng-model="user.username">
</td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>
Email
</td>
<td>
<input type="email" ng-bind="user.email" ng-model="user.email">
</td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>
Password
</td>
<td>
<input type="text" ng-bind="user.password1" ng-model="user.email">
</td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>
Retype password
</td>
<td>
<input type="text" ng-bind="user.password2" ng-model="user.password">
</td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>
Date of Birth
</td>
<td>
<input type="text" ng-bind="user.dobDay" ng-model="user.password" value="DD" size="2" maxlength="2">
<input type="text" ng-bind="user.dobMonth" ng-model="user.password" value="MM" size="2" maxlength="2">
<input type="text" ng-bind="user.dobYear" ng-model="user.password" value="YYYY" size="4" maxlength="4">
</td>
</tr>
<tr>
<td>
Profile picture
</td>
<td>
<input type="file" ng-bind="profile_picture">
</td>
</tr>
<tr>
<td></td>
<td style="float:left">
<button ng-click="submit()">Submit</button>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
Clicking the button doesn't seem to trigger any action. Any insights on what might be going wrong? Still getting acquainted with AngularJS. Appreciate any guidance.