This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var myApp = angular.module('myApp',['ngRoute']); | |
| myApp.config(['$routeProvider','$locationProvider', | |
| function($routeProvider, $locationProvider) { | |
| $routeProvider | |
| .when('/home', { | |
| templateUrl: 'templates/home.html', | |
| controller: 'HomeController' | |
| }) | |
| .when('/contacts', { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| myApp.service('ContactService', ['$http',function($http){ | |
| this.getContacts = function(){ | |
| var promise = $http.get('contacts') | |
| .then(function(response){ | |
| return response.data; | |
| },function(response){ | |
| alert('error'); | |
| }); | |
| return promise; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Entity | |
| public class Person implements Serializable | |
| { | |
| private static final long serialVersionUID = 1L; | |
| @Id @GeneratedValue(strategy=GenerationType.AUTO) | |
| private Integer id; | |
| private String email; | |
| private String password; | |
| private String firstname; | |
| private String lastname; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| myApp.controller('TodoController', [ '$scope', 'TodoService', function ($scope, TodoService) { | |
| $scope.newTodo = {}; | |
| $scope.loadTodos = function(){ | |
| TodoService.loadTodos(). | |
| success(function(data, status, headers, config) { | |
| $scope.todos = data; | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var myApp = angular.module('myApp'); | |
| myApp.factory('TodoService', function($http){ | |
| return { | |
| loadTodos : function(){ | |
| return $http.get('todos'); | |
| }, | |
| createTodo: function(todo){ | |
| return $http.post('todos',todo); | |
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| angular.module('myApp') | |
| .provider('UserService', function() { | |
| return { | |
| this.$get = function($http) { | |
| var service = this; | |
| this.user = {}; | |
| this.login = function(email, pwd) { | |
| $http.get('/auth',{ username: email, password: pwd}).success(function(data){ | |
| service.user = data; | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| angular.module('myApp') | |
| .service('UserService', ['$http',function($http) { | |
| var service = this; | |
| this.user = {}; | |
| this.login = function(email, pwd) { | |
| $http.get('/auth',{ username: email, password: pwd}).success(function(data){ | |
| service.user = data; | |
| }); | |
| }; | |
| this.register = function(newuser) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| angular.module('myApp') | |
| .factory('UserService', ['$http',function($http) { | |
| var service = { | |
| user: {}, | |
| login: function(email, pwd) { | |
| $http.get('/auth',{ username: email, password: pwd}).success(function(data){ | |
| service.user = data; | |
| }); | |
| }, | |
| register: function(newuser) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| myApp.controller('TodoController',['$scope','$http',function($scope,$http){ | |
| var todoCtrl = this; | |
| todoCtrl.todos = []; | |
| todoCtrl.loadTodos = function(){ | |
| $http.get('/todos.json').success(function(data){ | |
| todoCtrl.todos = data; | |
| }).error(function(){ | |
| alert('Error in loading Todos'); | |
| }); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| angular.module('myApp') | |
| .controller('TodoController', [ '$scope', '$http', function ($scope, $http) { | |
| $scope.newTodo = {}; | |
| $scope.loadTodos = function(){ | |
| $http.get('todos') | |
| .success(function(data, status, headers, config) { | |
| $scope.todos = data; |