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

$ionicPlatform.ready() not working?

$
0
0

@Pablo74 wrote:

.controller("appController", function($ionicPlatform, $cordovaFile){...}

Inside this controller I have a function:
this.readFromFile = function(){
$cordovaFile.readAsText(cordova.file.dataDirectory, "data.txt")
.then(function (success) {
this.content = success;
this.content = this.content.replace(/\"/gmi, '"');
this.shops = [];
this.shops = JSON.parse(this.content);
}.bind(this), function (error) {
}
);
};

This function is called from button's touch event, it works.

But, when I put this function inside ionicPlatform.ready(), I think it should be called automatically, but not.

This code is NOT working, I have no idea why:
$ionicPlatform.ready(function(){
$cordovaFile.readAsText(cordova.file.dataDirectory, "data.txt")
.then(function (success) {
this.content = success;
this.content = this.content.replace(/\"/gmi, '"');
this.shops = [];
this.shops = JSON.parse(this.content);
}.bind(this), function (error) {
}
);
});

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 49173

Trending Articles