Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function(angular) {
- 'use strict';
- var connectMangasApp = angular.module('ConnectMangasApp', ['ngRoute']);
- connectMangasApp.config(function($routeProvider, $httpProvider) {
- $httpProvider.defaults.headers.post['Client-Service'] = 'frontend-client';
- $httpProvider.defaults.headers.post['Auth-Key'] = 'simplerestapi';
- $httpProvider.defaults.headers.post['Access-Control-Allow-Origin'] = '*';
- $httpProvider.defaults.headers.post['X-Content-Type-Options'] = 'nosniff';
- $httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
- $routeProvider.when('/', {
- templateUrl: 'pages/auth.html',
- controller: 'AuthController'
- }).otherwise({
- redirectTo: '/'
- });
- });
- connectMangasApp.factory('authService', function($http) {
- return {
- register: function(username, password, email) {
- return $http({
- method: 'POST',
- url: 'http://localhost/jg/ConnectMangas/server/UserController/register',
- data: { username: username, password: password, email: email }
- }).then(function(response) {
- console.log(repsonse);
- /* var registerInfos = response.data.infos;
- return registerInfos; */
- });
- }
- }
- /* var register = function(username, password, email) {
- return $http({
- method: 'POST',
- url: 'http://localhost/jg/ConnectMangas/server/UserController/register',
- data: { username: username, password: password, email: email }
- }).then(function(response) {
- console.log(response);
- });
- };
- return { register: register }; */
- });
- connectMangasApp.controller('AuthController', function($scope, authService) {
- $scope.register = function() {
- var username = $scope.register.username;
- var password = $scope.register.password;
- var email = $scope.register.email;
- if ( typeof username != 'undefined' && typeof password != 'undefined' && typeof email != 'undefined' ) {
- var registerPromise = authService.register(username, password, email);
- console.log(registerPromise);
- registerPromise.then(function(registerResult) {
- console.log(registerResult);
- });
- }
- }
- });
- })(window.angular);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement