Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49166

Ng-if="check(document)"

$
0
0

@ervinsotm wrote:

Hello guys!

I really need your help, this is more angular specified trouble. I have created ng-click test button

<ion-item ng-repeat="document in filtered = (documents | filter: searchFilter | filter: {category_id: categoryFilter.id}: false | orderBy: sortBy)"  type="item-text-wrap">
          <form class="view-form" name="viewForm" method="post" ng-submit="open(document, user)">
            <button type="submit"><img class="document-image" image-lazy-src="{{::url + document.thumbnail }}" alt="" image-lazy-loader="ios"/></button>
          </form>
          <div class="document-title" ng-if="document.title.length <= 25">{{::document.title}} <span class="document-size">({{::document.size | filesize:2}})</span></div>
          <div class="document-title" ng-if="document.title.length > 25">{{::document.title | limitTo: 25}} ...<span class="document-size"> ({{::document.size | filesize:2}})</span></div>
          <div class="document-functions">
            <form name="downloadForm" method="post" ng-submit="download(document)">
              <button class="buttons button-document-save">Save</button>
            </form>
            <button ng-click="check(document)">Test</button>
            <pre>{{ download }}</pre>
            <form name="sendForm" method="post" ng-submit="send(document, user, data)">
              <button class="buttons button-document-send" >Email file</button>
            </form>
          </div>
        </ion-item>

with function

 .controller('DocumentCtrl', function($http, $scope, $ionicPopup, $timeout, $cordovaFileTransfer,$cordovaFile, $window, localStorageService) {
$scope.check = function(document) {
      var url = baseUrl + document.image;
      var filename = url.split("/").pop();
      $cordovaFile.checkFile(cordova.file.documentsDirectory, filename)
      .then(function(success) {
        $scope.download = success;
      }, function(error) {
        $scope.download = error;
      });
    };
})

which returns, if image path exists. I've tried this function with ng-if, it returns infinite loop error, have no idea why.
The idea is not to show document download button, if image path exists.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 49166

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>