Skip to content

Commit d4e3f76

Browse files
committed
fix(README.md): bind example
1 parent 9cf1e07 commit d4e3f76

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

README.md

+16-7
Original file line numberDiff line numberDiff line change
@@ -223,18 +223,27 @@ Bind $scope key to localStorageService.
223223
myApp.controller('MainCtrl', function($scope, localStorageService) {
224224
//...
225225
localStorageService.set('property', 'oldValue');
226-
var unbind = localStorageService.bind($scope, 'property');
226+
$scope.unbind = localStorageService.bind($scope, 'property');
227227

228228
//Test Changes
229-
$scope.property = 'newValue1';
230-
console.log(localStorageService.get('property')) // newValue1;
231-
//unbind watcher
232-
unbind();
233-
$scope.property = 'newValue2';
234-
console.log(localStorageService.get('property')) // newValue1;
229+
$scope.update = function(val) {
230+
$scope.property = val;
231+
$timeout(function() {
232+
alert("localStorage value: " + localStorageService.get('property'));
233+
});
234+
}
235235
//...
236236
});
237237
```
238+
```html
239+
<div ng-controller="MainCtrl">
240+
<p>{{property}}</p>
241+
<input type="text" ng-model="lsValue"/>
242+
<button ng-click="update(lsValue)">update</button>
243+
<button ng-click="unbind()">unbind</button>
244+
</div>
245+
```
246+
238247
###deriveKey
239248
Return the derive key
240249
**Returns** `String`

0 commit comments

Comments
 (0)