Quantcast
Channel: Ionic Forum - Latest posts
Viewing all articles
Browse latest Browse all 228603

Display Problem

$
0
0

I added two alert () "SUCCESS A" and "SUCCESS B "
it displays first "SUCCESS B" empty.
and "SUCCESS A" with [{"id":"1","name":"ABC"}, {"id":"2","name":"DEF"}]

var items = [];
app.service('itemProvider', function($ionicPlatform,$cordovaFile) {
    this.getItems = function () {
        $ionicPlatform.ready(function () {
            // READ
           $cordovaFile.readAsText(cordova.file.dataDirectory, "test.json")
                 .then(function (success) {
                        // success
                        items = success;
                        alert("SUCCESS A : >> " + items);
                 }, function (error) {
                        // error
                        alert("ERROR:" + error);
                 });
        });
        alert("SUCCESS B : >> " + items);
        return items;
    }
})

Viewing all articles
Browse latest Browse all 228603

Trending Articles



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