Skip to content

Instantly share code, notes, and snippets.

@pankajpatel
Last active August 29, 2015 14:22
Show Gist options
  • Save pankajpatel/ad6eb8e6cb090f12c6f5 to your computer and use it in GitHub Desktop.
Save pankajpatel/ad6eb8e6cb090f12c6f5 to your computer and use it in GitHub Desktop.
Complete app.js for contact store application
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