当我关闭应用程序时,在离子框架中保存书签或收藏项目

时间:2015-07-11 08:21:50

标签: android save load ionic-framework ionic

我有一个项目列表,我标记了其中一些。 当我关闭应用程序并打开它aggain,标记被删除。 请帮我保存并加载应用

list.html

<ion-view class="text-center bfont" view-title="کافی شاپ">
  <ion-nav-buttons side="left">
    <button class="button button-icon ion-help-circled" ng-click="openModal()"></button>
  </ion-nav-buttons>
  <ion-nav-buttons side="right">
    <button class="button button-icon ion-gear-a" ng-click()="openModal()"></button>
  </ion-nav-buttons>
  <div class="bar bar-subheader item-input-inset bar-light">
    <label class="item-input-wrapper">
      <i class="icon ion-search placeholder-icon"></i>
      <input type="search" class="text-right" ng-model="query" placeholder="جست و جو">
    </label>
  </div>
  <ion-content class="has-subheader">
    <ion-list>
      <ion-item ng-class="{'star':item.star}" ng-repeat='item in artists | filter: query' class="item-thumbnail-right item-icon-left item-text-wrap" href="#/tab/list/{{item.shortname}}">
      <img ng-src="img/img/{{item.shortname}}.jpg" alt="{{item.name}} Photo">
        <h3 class="text-right bfont">{{item.name}}</h3>
        <p class="bfont" style="direction:rtl; text-align:justify">{{item.shortbio | limitTo: 100}}
      {{ item.shortbio.length > 150 ? '&hellip;' : '' }}</p>
      <button class="button button-clear icon ion-star button-assertive"
        ng-click="toggleStar(item)"
        ng-show="item.star"></button>
      <ion-option-button class="button-assertive"
        ng-click="toggleStar(item)">
        <i class="icon ion-star"></i>
      </ion-option-button>
      </ion-item>
    </ion-list>
  </ion-content>
</ion-view>

app.js

// Ionic Starter App

// angular.module is a global place for creating, registering and retrieving Angular modules
// 'starter' is the name of this angular module example (also set in a <body> attribute in index.html)
// the 2nd parameter is an array of 'requires'
angular.module('starter', ['ionic'])

.run(function($ionicPlatform) {
  $ionicPlatform.ready(function() {
    // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
    // for form inputs)
    if(window.cordova && window.cordova.plugins.Keyboard) {
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
    }
    if(window.StatusBar) {
      StatusBar.styleDefault();
    }
  });
})

.config(function($stateProvider, $urlRouterProvider, $ionicConfigProvider) {
  $ionicConfigProvider.tabs.position('bottom');

  $stateProvider
    .state('tabs', {
      url: '/tab',
      abstract: true,
      templateUrl: 'templates/tabs.html'
    })
    .state('tabs.home', {
      url: '/home',
      views: {
        'home-tab': {
          templateUrl: 'templates/home.html'
        }
      }
    })
    .state('tabs.list', {
      url: '/list',
      views: {
        'list-tab': {
          templateUrl: 'templates/list.html',
          controller: 'ListController'
        }
      }
    })
    .state('tabs.detail', {
      url: '/list/:aId',
      views: {
        'list-tab': {
          templateUrl: 'templates/detail.html',
          controller: 'ListController'
        }
      }
    })
  $urlRouterProvider.otherwise('tab/home');
})

.controller('AppCtrl', function($scope, $ionicModal) {
  $ionicModal.fromTemplateUrl('templates/help.html', {
    scope: $scope,
    animation: 'slide-in-up'
  }).then(function(modal) {
    $scope.modal = modal;
  });
  $scope.openModal = function() {
    $scope.modal.show();
  };
  $scope.closeModal = function() {
    $scope.modal.hide();
  };
})

.controller('ListController', ['$scope', '$http', '$state', 
  function($scope, $http, $state) {
    $http.get('js/data.json').success(function(data){
      $scope.artists = data;
      $scope.whichartist = $state.params.aId;
      $scope.toggleStar = function(item) {
        item.star = !item.star;
      }
  });
}]);

的index.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">
    <title></title>

    <link href="lib/ionic/css/ionic.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">
    <link href="css/font.css" rel="stylesheet">

    <!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above
    <link href="css/ionic.app.css" rel="stylesheet">
    -->

    <!-- ionic/angularjs js -->
    <script src="lib/ionic/js/ionic.bundle.js"></script>

    <!-- cordova script (this will be a 404 during development) -->
    <script src="cordova.js"></script>

    <!-- your app's js -->
    <script src="js/app.js"></script>
  </head>
  <body ng-app="starter" ng-controller="AppCtrl">
    <ion-nav-bar class="bar-energized bfont">
      <ion-nav-back-button class="bfont">بازگشت </ion-nav-back-button>
    </ion-nav-bar>
    <ion-nav-view></ion-nav-view>
  </body>
</html>

tabs.html

<ion-tabs class="tabs-icon-top tabs-energized bfont">
    <ion-tab title="خانه" icon="ion-home"
  href="#/tab/home">
    <ion-nav-view name="home-tab"></ion-nav-view>
  </ion-tab>
    <ion-tab class="text-center" title="کافی شاپ" icon="ion-coffee" href="#/tab/list">
        <ion-nav-view name="list-tab"></ion-nav-view>
    </ion-tab>
</ion-tabs>

我标记了一个项目,当我关闭未标记的应用项目时,我的项目在JSON文件中 请帮我保存标记。

0 个答案:

没有答案