Appgyver 类固醇,Web 视图中更新的对象不会显示

Appgyver Steroids, updated object in Web View won't show

本文关键字:对象 显示 更新 类固醇 Web 视图 Appgyver      更新时间:2023-09-26

>我正在开发一个带有Appgyver Steroids和AngularJs的HTML5移动应用程序。该应用程序使用全局 javascript 对象来填充有关步骤的信息,并由整个应用程序使用。一切都运行良好,直到我需要创建一个图库.html并从我的主控制器将其推送为 Web 图层。主.html和画廊.html都有自己的控制器。图库.html按预期显示 javascript 对象中的所有图片,当我删除它们时,它们也会按预期从 javascript 对象中删除。但是,当我回到主.html然后单击"画廊"时,它们都再次出现在画廊.html中。

我认为一定是范围问题还是多个实例的问题?如何获得图库.html以读取实际对象(删除后没有图片的对象)?为什么库.html不更新其值?我一直在运行代码,它没有错,但是当我在 Web 层中使用它时,就会发生这种情况。

在主控制器中:

$scope.gallery = function(roomId, detailId) {
    pictures = inspectionService.getPictures(roomId, detailId);
    if (pictures.length > 0) {
        webView = new steroids.views.WebView("/views/inspection/gallery.html?roomId=" + roomId + '&detailId=' + detailId);
        steroids.layers.push(webView);
    } else {
        this.camera();
    }
};

在库控制器中:

function init(){
    roomId = steroids.view.params.roomId;
    detailId = steroids.view.params.detailId;
    updateGallery();
}
//UPDATING GALLERY
function updateGallery() {
    $scope.pictures = inspectionService.getPictures(roomId, detailId);
    $scope.info = inspectionService.getRoom(roomId).name + ": " + inspectionService.getDetail(roomId, detailId).name;
};
//REMOVE PICTURE
$scope.removePicture = function(pictureUri) {
    inspectionService.removePicture(roomId, detailId, pictureUri);
    updateGallery();
    if (pictures.length <= 0) {
        steroids.layers.pop();
    }
};

AppGyver 员工在这里!类固醇中的 WebViews 是独立的"浏览器"实例,每个实例都有自己的 DOM 和 JavaScript 运行时。我写了一个关于这个主题的快速指南,看看:http://guides.appgyver.com/steroids/guides/steroids-js/sharing-data-between-webviews/

基本上,您需要确保在不同的视图之间保持inspectionService状态 - 指南中关于使用后台HTML WebView的最后一部分应该很有用!