File tree 1 file changed +16
-7
lines changed
1 file changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -223,18 +223,27 @@ Bind $scope key to localStorageService.
223
223
myApp .controller (' MainCtrl' , function ($scope , localStorageService ) {
224
224
// ...
225
225
localStorageService .set (' property' , ' oldValue' );
226
- var unbind = localStorageService .bind ($scope, ' property' );
226
+ $scope . unbind = localStorageService .bind ($scope, ' property' );
227
227
228
228
// 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
+ }
235
235
// ...
236
236
});
237
237
```
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
+
238
247
###deriveKey
239
248
Return the derive key
240
249
** Returns** ` String `
You can’t perform that action at this time.
0 commit comments