Skip to content

Instantly share code, notes, and snippets.

@Istenes
Last active August 29, 2015 14:07
Show Gist options
  • Save Istenes/07382efd0260b4d64c62 to your computer and use it in GitHub Desktop.
Save Istenes/07382efd0260b4d64c62 to your computer and use it in GitHub Desktop.
<html ng-app="myApp">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-rc.3/angular.min.js"></script>
<script type="text/javascript">
console.log("hello")
var app = angular.module("myApp", []);
app.value("user", {
name: "username",
country: "country",
phone: "phone"
});
app.controller("TestCtrl", function(user, $scope, $http) {
console.log(user);
$scope.user = user;
$scope.login = function() {
console.log($scope.username);
console.log($scope.password);
var data = {
username: $scope.username,
password: $scope.password
}
$http.post("login", data).success(function(response) {
$scope.user.name = response.name;
$scope.user.country = response.country;
$scope.user.phone = response.phone;
console.log(response);
});
}
});
</script>
</head>
<body>
<div ng-controller="TestCtrl">
Name: {{user.name}} <br />
Country: {{user.country}}<br />
Phone: {{user.phone}}<br />
<input ng-model="username" />
<input ng-model="password" type="password"/>
<button ng-click="login()">Login</button>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment