angularjs - Ionic framework,Angular Js -


the problem have been facing after json.parse(localstorage.getitem('user_info'))); how can put string in $scope object ?

please suggest problem.

thanks in advance

you'll need define angularjs controller , bind ionic view ng-controller directive. below example — recommend playing around on play.ionic.io.

js

angular.module('app', ['ionic']).controller('mycontroller', function($scope) {    // localstorage.setitem('user_info', json.stringify('hello world'));   $scope.userinfo = json.parse(localstorage.getitem('user_info'));  }); 

html

<!doctype html> <html>   <head>     <meta charset="utf-8">     <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">     <link href="https://code.ionicframework.com/1.0.0/css/ionic.min.css" rel="stylesheet">     <script src="https://code.ionicframework.com/1.0.0/js/ionic.bundle.js"></script>   </head>   <body ng-app="app">     <ion-pane>       <ion-header-bar class="bar-stable">         <h1 class="title">localstorage example</h1>       </ion-header-bar>       <ion-content class="padding" ng-controller="mycontroller">         <h1>{{userinfo}}</h1>       </ion-content>     </ion-pane>   </body> </html> 

Comments