Hi all, quite new to angular, as will become obvious.
I have a simple form with two fields (user pass)
I wish to display the user and pass below the form when clicked.
When the form button is clicked, the console log says success (small
victory)
However, I do not see the data on the loginform.html page.
All help gratefully received.
Kevin
### login.html ###
<!DOCTYPE html>
<html ng-app>
<head>
<title>Login Stuff</title>
<script
src="http://code.angularjs.org/angular-1.0.0.min.js"></script>
<script src="login.js"></script>
</head>
<body>
<div ng-controller="LoginCtrl">
<form>
<label>Login:</label>
<input type="text" name="user" placeholder="Username">
<input type="text" name="pass" placeholder="password">
<button type="submit" ng-click="login()">Login</button>
</form>
{{result}}
</div>
</body>
</html>
### login.js ###
function LoginCtrl($scope, $http) {
$scope.url = 'login.php'; // The url of our login
// The function that will be executed on button click
(ng-click="login()")
$scope.login = function() {
// Create the http post request
// the data holds the keywords
// The request is a JSON request.
//
$http.post($scope.url, { "user":$scope.user,
"pass":$scope.pass}).
success(function(data, status) {
$scope.status = status;
$scope.data = $scope.user+$scope.pass;
$scope.result = $scope.user+$scope.pass;
console.log('success');
}).
error(function(data, status) {
$scope.data = user+pass;
$scope.status = status;
console.log('fail');
})
};
}
### login.php ###
<?php
$data = file_get_contents("php://input");
$objData = json_decode($data);
echo $objData->user;
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.