离子应用程序中的书签文章

时间:2016-05-17 14:04:35

标签: angularjs ionic-framework

如何在离子应用程序中为文章添加书签

<div class="container"  on-tap="toggleHeader()" > 
    <!-- on-tap="toggleHeader()" -->
    <div id="test" class="slideItem" ng-class="{'list list-inset-hide': Aindex  > $index + 1, 'back-items': Aindex < $index+1}" ng-repeat="Listnews in AllnewsList" ng-style="{'height':'{{hgt}}','z-index': (AllnewsList.length - $index)}" on-swipe-up="swipeUp($event)"   on-swipe-down="swipeDown($event)">
        <div ng-class="{'satin': Aindex < $index+1, 'not-satin': Aindex != $index}" >
          </div>
          <ul class="list-unstyled cs-tag-item-grp newsDiv">
              <li class="clearfix">
                  <div class="newsCnt">
                      <div ng-show="Listnews.ImageUrl !=' ' " class="newsImageContainer">
                          <img  class="newsImage" ng-src="{{Listnews.ImageUrl}}"/>
                      </div>
                      <div class="newTitle pLR5">{{Listnews.Heading}}</div>
                      <div class="newsDisc pLR5">{{Listnews.Para | limitTo: 300}} {{Listnews.Para.length > 300 ? '&hellip;':''}}</div>
                      <div class="newsEdit pLR5"><strong>Starticle</strong> by - {{Listnews.Editor}} / {{Listnews.PublishedDate | date:'dd  MMM'}} </div>
                      <div class="newSrc pLR5" ng-show="Listnews.SourceLink" >more at - <a ng-href="{{Listnews.SourceLink}}" onclick="window.cordova.InAppBrowser.open(this.href, '_blank', 'location=yes'); return false;">{{Listnews.SourceName}}</a> 
                      </div>
                      <div class="tabs tabs-icon-only" >
                          <a class="tab-item" >
                              <a class="button  icon ion-share" ng-click="shareAnywhere(Listnews.ImageUrl,Listnews.Heading,Listnews.Para,Listnews.SourceLink)"></a>
                          </a>
                          <a class="tab-item">
                              <a ng-show="!bookmarkstate" class="button icon ion-ios-bookmarks-outline" ng-click="bookmark(true)"></a>
                          <a ng-show="bookmarkstate" class="button icon ion-ios-bookmarks" ng-click="bookmark(false)"></a>
                          </a>
                          <a class="tab-item">
                              <a class="button icon ion-chatbox-working" ng-click="commentModalopen()"></a>
                          </a>                                          
                      </div>
                  </div>
              </li>
          </ul>
      </div>
  </div>      
  </div>

书签功能

$scope.bookmark = function(state) 
{

 $scope.info = null;
 if(!localStorage.getItem("localnews")){

  var book_data = {data: []};
  var notID = 0 ;
  window.localStorage.setItem("book_data", JSON.stringify(book_data));
  window.localStorage.setItem("id", JSON.stringify(notID));
 }

 $scope.info = JSON.parse(window.localStorage.getItem("book_data"));
$scope.bookmarkstate = state


var page = document.getElementById("localnews").value;

if(page == null)
{
 alert("Bookmark Not added");
  return;
}
  var id = JSON.parse(window.localStorage.getItem("book_data"));


      var array = {id:id};
      $scope.info.data[$scope.info.data.length] = array;
      window.localStorage.setItem("rp_data", JSON.stringify($scope.info));
      window.localStorage.setItem("id", JSON.stringify(id + 1));
      alert("Bookmark Added")


     document.getElementById("Aindex").value =" ";


       $scope.getBookmarked();
}

0 个答案:

没有答案