Skip to content

Instantly share code, notes, and snippets.

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

K. Siva Prasad Reddy sivaprasadreddy

:octocat:
Learning and practicing...
View GitHub Profile
@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;
@sivaprasadreddy
sivaprasadreddy / hello-ang-home.html
Last active August 29, 2015 14:06
hello-ang-home.html
<div class="col-md-8 col-md-offset-2">
<form class="form-horizontal" role="form">
<div class="form-group form-group-md">
<div class="col-md-10">
<input type="text" class="form-control" ng-model="newTodo.description">&nbsp;
</div>
<button class="btn btn-primary" ng-click="addTodo(newTodo)">Add</button>
</div>
</form>
@sivaprasadreddy
sivaprasadreddy / hello-ang-final-index.html
Created September 4, 2014 12:54
hello-angular-final-index.html
<!doctype html>
<html ng-app="myApp">
<head>
<meta charset="utf-8"/>
<title>DashBoard</title>
<link rel="stylesheet" href="webjars/bootstrap/3.2.0/css/bootstrap.css"/>
<link rel="stylesheet" href="webjars/font-awesome/4.1.0/css/font-awesome.css"/>
<link rel="stylesheet" href="css/styles.css"/>
@sivaprasadreddy
sivaprasadreddy / hello-ang-app.js
Created September 4, 2014 12:53
HelloAngular app.js
var myApp = angular.module('myApp',['ngRoute']);
myApp.config(['$routeProvider','$locationProvider',
function($routeProvider, $locationProvider) {
$routeProvider
.when('/home', {
templateUrl: 'templates/home.html',
controller: 'TodoController'
})