I'm trying to hook a few variables up to a function in AngularJS and while they appear to be making it to the front end, the changes made on the front end don't transfer to the back end.
Here's the relevant portion of the body:
<body ng-controller="main-controller">
<div ng-show="show_login" ng-include="'/racket-web/view/login.html'">
</body>
And what it includes
<table>
<tr>
Email <input ng-model="login_email"/> {{login_email}} <br>
Pass <input type="password" ng-model="login_password"/> {{login_password}}<br>
<button ng-click="exec_login()">Login</button>
</tr>
</table>
Here's my controller
app.controller('main-controller', function($scope) {
$scope.login_email = 'abcd';
$scope.login_password = 'defg';
$scope.changeView = function(view) {
$scope['show_login'] = false;
// other views snipped
$scope['show_' + view] = true;
}
$scope.changeView('login');
$scope.exec_login = function() {
var email = $scope.login_email;
var pass = $scope.login_password;
alert('logging in ' + email + ' ' + pass);
}
When I run my page, I do see my email and pass inputs as expected, and when I edit them the debug values next to the inputs change appropriately. However, when I click the button, the alertbox still has the original values.
How can I get the values acquired inside the function to see the latest version in the input box? I know I could use VanillaJS to grab them, but I'd rather use proper Angular!
Here's a screengrab of what I'm seeing: