File tree Expand file tree Collapse file tree 1 file changed +16
-7
lines changed Expand file tree Collapse file tree 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.
223223myApp .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
239248Return the derive key
240249** Returns** ` String `
You can’t perform that action at this time.
0 commit comments