fix(README.md): bind example

master
Ariel Mashraki 10 years ago
parent 9cf1e0729d
commit d4e3f76c38

@ -223,18 +223,27 @@ Bind $scope key to localStorageService.
myApp.controller('MainCtrl', function($scope, localStorageService) { myApp.controller('MainCtrl', function($scope, localStorageService) {
//... //...
localStorageService.set('property', 'oldValue'); localStorageService.set('property', 'oldValue');
var unbind = localStorageService.bind($scope, 'property'); $scope.unbind = localStorageService.bind($scope, 'property');
//Test Changes //Test Changes
$scope.property = 'newValue1'; $scope.update = function(val) {
console.log(localStorageService.get('property')) // newValue1; $scope.property = val;
//unbind watcher $timeout(function() {
unbind(); alert("localStorage value: " + localStorageService.get('property'));
$scope.property = 'newValue2'; });
console.log(localStorageService.get('property')) // newValue1; }
//... //...
}); });
``` ```
```html
<div ng-controller="MainCtrl">
<p>{{property}}</p>
<input type="text" ng-model="lsValue"/>
<button ng-click="update(lsValue)">update</button>
<button ng-click="unbind()">unbind</button>
</div>
```
###deriveKey ###deriveKey
Return the derive key Return the derive key
**Returns** `String` **Returns** `String`