Skip to content

Commit

Permalink
add angularLocalStorage type files
Browse files Browse the repository at this point in the history
  • Loading branch information
horiuchi committed May 12, 2014
1 parent e9b0f60 commit ff509b3
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ All definitions files include a header with the author and editors, so at some p
* [AmCharts](http://www.amcharts.com/) (by [Covobonomo](https://github.com/covobonomo/))
* [AngularFire](https://www.firebase.com/docs/angular/reference.html) (by [Dénes Harmath](https://github.com/thSoft))
* [AngularJS](http://angularjs.org) (by [Diego Vilar](https://github.com/diegovilar)) ([wiki](https://github.com/borisyankov/DefinitelyTyped/wiki/AngularJS-Definitions-Usage-Notes))
* [angularLocalStorage](https://github.com/agrublev/angularLocalStorage) (by [Hiroki Horiuchi](https://github.com/horiuchi/))
* [AngularUI](http://angular-ui.github.io/) (by [Michel Salib](https://github.com/michelsalib))
* [Angular Protractor](https://github.com/angular/protractor) (by [Bill Armstrong](https://github.com/BillArmstrong))
* [Angular Translate](http://pascalprecht.github.io/angular-translate/) (by [Michel Salib](https://github.com/michelsalib))
Expand Down
27 changes: 27 additions & 0 deletions angularLocalStorage/angularLocalStorage-tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
///<reference path="../angularjs/angular.d.ts" />
///<reference path="./angularLocalStorage.d.ts" />

interface TestScope extends ng.IScope {
viewType: string;
}

module angularLocalStorageTests {
export class TestController {
constructor(private $scope: TestScope, private storage: AngularLocalStorageService) {
storage.bind($scope, 'varName');
storage.bind($scope,'varName', { defaultValue: 'randomValue123', storeName: 'customStoreKey' });
$scope.viewType = 'ANYTHING';
storage.unbind($scope, 'viewType');

storage.set('key', 'value');
storage.get('key');
storage.remove('key');

storage.clearAll();
}
}
}

var app = angular.module('angularLocalStorageTests', ['angularLocalStorage']);
app.controller('testCtrl', ['$scope', 'storage', ($scope: TestScope, storage: AngularLocalStorageService) => new angularLocalStorageTests.TestController($scope, storage)]);

20 changes: 20 additions & 0 deletions angularLocalStorage/angularLocalStorage.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Type definitions for AngularLocalStorage 0.1.7
// Project: https://github.com/agrublev/angularLocalStorage
// Definitions by: Horiuchi_H <https://github.com/horiuchi/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped

/// <reference path="../angularjs/angular.d.ts"/>

interface AngularLocalStorageService {
set(key: string, value: any): any;
get(key: string): any;
remove(key: string): boolean;
clearAll(): void;

bind($scope: ng.IScope, key: string, opts?: {
defaultValue?: any;
storeName?: string;
}): any;
unbind($scope: ng.IScope, key: string, storeName?: string): void;
}

0 comments on commit ff509b3

Please sign in to comment.