Last active
August 29, 2015 14:22
-
-
Save pankajpatel/ad6eb8e6cb090f12c6f5 to your computer and use it in GitHub Desktop.
Complete app.js for contact store application
This file contains 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 app = angular.module( 'contactApp', ['ngRoute'] ); | |
app | |
.config(['$routeProvider', | |
function($routeProvider) { | |
$routeProvider | |
.when('/contacts', { | |
templateUrl: 'js/partials/contacts.html', | |
controller: 'ContactsController' | |
}) | |
.when('/contacts/:index', { | |
templateUrl: 'js/partials/contact.html', | |
controller: 'ContactController' | |
}) | |
.when('/add', { | |
templateUrl: 'js/partials/contact.new.html', | |
controller: 'EditContactController' | |
}) | |
.when('/edit/:index', { | |
templateUrl: 'js/partials/contact.new.html', | |
controller: 'EditContactController' | |
}) | |
.otherwise({ | |
redirectTo: '/contacts' | |
}); | |
}]) | |
.factory('storage', ['$window', function( $window ){ | |
return { | |
memorize: function( key, value ){ | |
try{ | |
if( $window.Storage ){ | |
$window.sessionStorage.setItem( key, $window.JSON.stringify( value ) ); | |
return true; | |
} else { | |
return false; | |
} | |
} catch( error ){ | |
console.error( error, error.message ); | |
} | |
return false; | |
}, | |
recall: function( key ){ | |
try{ | |
if( $window.Storage ){ | |
return $window.JSON.parse( $window.sessionStorage.getItem( key ) ) | |
} else { | |
return false; | |
} | |
} catch( error ){ | |
console.error( error, error.message ); | |
} | |
return false; | |
} | |
} | |
}]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment