Skip to content

Instantly share code, notes, and snippets.

View sivaprasadreddy's full-sized avatar
:octocat:
Learning and Teaching

K. Siva Prasad Reddy sivaprasadreddy

:octocat:
Learning and Teaching
View GitHub Profile
@sivaprasadreddy
sivaprasadreddy / app-1.js
Created September 5, 2014 12:16
app-1.js
var myApp = angular.module('myApp',['ngRoute']);
myApp.config(['$routeProvider','$locationProvider',
function($routeProvider, $locationProvider) {
$routeProvider
.when('/home', {
templateUrl: 'templates/home.html',
controller: 'HomeController'
})
.when('/contacts', {
@sivaprasadreddy
sivaprasadreddy / Contact-Service-Ctrl.js
Created September 5, 2014 12:15
Contact-Service-Ctrl.js
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;
@sivaprasadreddy
sivaprasadreddy / Contact-Entity-Repo-Ctrl.java
Created September 5, 2014 12:14
Contact-Entity-Repo-Ctrl.java
@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;
@sivaprasadreddy
sivaprasadreddy / TodoController-1.js
Created September 5, 2014 12:14
TodoController-1.js
myApp.controller('TodoController', [ '$scope', 'TodoService', function ($scope, TodoService) {
$scope.newTodo = {};
$scope.loadTodos = function(){
TodoService.loadTodos().
success(function(data, status, headers, config) {
$scope.todos = data;
})
@sivaprasadreddy
sivaprasadreddy / TodoService-1.js
Created September 5, 2014 12:12
TodoService-1.js
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);
},
@sivaprasadreddy
sivaprasadreddy / provider-service.js
Created September 5, 2014 12:11
provider-service.js
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;
});
@sivaprasadreddy
sivaprasadreddy / service-service.js
Created September 5, 2014 12:10
service-service.js
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) {
@sivaprasadreddy
sivaprasadreddy / factory-service.js
Created September 5, 2014 12:10
factory-service.js
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) {
@sivaprasadreddy
sivaprasadreddy / TodoController-v1.js
Created September 5, 2014 12:09
TodoController-v1.js
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');
});
};
@sivaprasadreddy
sivaprasadreddy / hello-ang-controller.js
Created September 4, 2014 12:56
hello-ang-controller.js
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;