Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'use strict';
- angular.module('myApp.view3', ['ngRoute'])
- .config(['$routeProvider', function ($routeProvider) {
- $routeProvider.when('/view3', {
- templateUrl: 'view3/view3.html',
- controller: 'View3Ctrl'
- });
- }])
- .controller('View3Ctrl', ['$scope', '$http', function ($scope, $http) {
- $scope.myData = new Array();
- $scope.getDataFromServer = function () {
- $http({
- method: 'GET',
- url: 'http://localhost:8080/users'
- }).then(function successCallback(response) {
- $scope.myData = response.data;
- console.log(response.data);
- }, function errorCallback(response) {
- console.log(response);
- });
- };
- $scope.pushDataToServer = function () {
- var newObject;// = new Array();
- newObject.username=Username;
- newObject.firstname=firstname;
- newObject.lastname=lastname;
- newObject.email=email;
- newObject.password=password;
- newObject.phone=phone;
- var json = angular.toJson(newObject);
- $http({
- method: 'POST',
- url: 'http://localhost:8080/users',
- headers: {
- 'Content-Type': 'application/json',
- 'Accept': 'application/json'
- },
- data: json
- }).then(function successCallback(response) {
- console.log(response);
- $scope.getDataFromServer();
- }, function errorCallback(response) {
- console.log(response);
- });
- };
- }]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement