4

Appgyver Steroids と AngularJs を使用して HTML5 モバイル アプリを開発しています。アプリはグローバルな JavaScript オブジェクトを使用して、手順に沿って情報を入力しており、アプリケーション全体で使用されています。gallery.html を作成し、それをメイン コントローラーから Web レイヤーとしてプッシュする必要が生じるまで、すべてがうまく機能していました。main.html と gallery.html には独自のコントローラーがあります。Gallery.html は、javascript オブジェクトから期待どおりにすべての写真を表示します。それらを削除すると、期待どおり、javascript オブジェクトからも削除されます。しかし、main.html に戻って「gallery」をクリックすると、それらはすべて gallery.html に再び表示されます。

スコープの問題または複数のインスタンスの問題があるに違いないと思いますか? gallery.html に実際のオブジェクト (すべてが削除された後に写真がないもの) を読み取るにはどうすればよいですか? gallery.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();
    }
};
4

1 に答える 1