Hi Team:
I created an Angular service to pull list of installed apps in Firefox OS. In
this angular service I created Promise object to return list of apps, and that
promise object is used with "then" method to update an object in $scope.
Issue is: it's not updating the view first time Promise has been fulfilled.
Please see the code below.
privacyApp.factory('appList', function(){
var mozApps = window.navigator.mozApps;
var mozAppsMgmt = mozApps && mozApps.mgmt;
var promise = new Promise(function(resolve, reject) {
var req = mozAppsMgmt.getAll();
req.onsuccess = function success(evt) {
resolve(evt.target.result);
};
req.onerror = function error(evt) {
console.log('failed to get installed apps');
reject(req.error);
};
});
return promise;
});
I'm using Promise returned from above service in the controller of the page to
update a variable like this:
privacyApp.controller("appsController", function($scope, appList){
var appJSON = {};
$scope.apps = {};
appList.then(function(data){
for(var i=0;i<data.length;i++){
if(data[i].manifest.type !== "certified"){
appJSON[data[i].manifest.name] = data[i].manifest;
//appsList[data[i].manifest.name] = data[i].manifest;
}
}
$scope.apps = appJSON;
});
});
When the page is loaded first time it doesn't show anything, but it does show
the apps list when I re-open(come back and click again) that page (route on
angular) again.
Thank you.
_______________________________________________
dev-fxos mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-fxos