Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/453.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Ng重复不更新视图_Javascript_Html_Angularjs - Fatal编程技术网

Javascript Ng重复不更新视图

Javascript Ng重复不更新视图,javascript,html,angularjs,Javascript,Html,Angularjs,我读过很多类似问题的人的问题线索,但他们没有解决我的问题 这是完整的代码(不包括CSS部分: <script> var app = angular.module("game", []); app.controller("controlematrix",function($scope) { $scope.undo = [];

我读过很多类似问题的人的问题线索,但他们没有解决我的问题

这是完整的代码(不包括CSS部分:

 <script>                                       

   var app = angular.module("game", []);
   app.controller("controlematrix",function($scope)
        {   
            $scope.undo = [];
            $scope.matriz = [ 2,2,2,2,2,2,2
                             ,2,2,2,0,0,0,2
                             ,2,3,0,0,0,0,2
                             ,2,0,0,0,0,0,2                    
                             ,2,3,0,0,2,0,2
                             ,2,0,0,0,0,0,2  
                             ,2,2,2,2,2,2,2];

            $scope.posx = 5;
            $scope.posy = 3;

            $scope.testeshow= function(atual){                  
                return (($scope.posx + $scope.posy * 7) != atual);  
            }

            $scope.up = function() {
                if($scope.matriz[$scope.posx + ($scope.posy-1) * 7] != 2)
                {
                    $scope.posy--;
                }
            }
            $scope.down = function() {
                if($scope.matriz[$scope.posx + ($scope.posy+1) * 7] != 2)
                {
                    $scope.posy++;
                }
            }
            $scope.left = function() {
                if($scope.matriz[($scope.posx-1) + $scope.posy * 7] != 2)
                {
                    $scope.posx--;
                }
            }
            $scope.right = function() {
                if($scope.matriz[($scope.posx+1) + $scope.posy * 7] != 2)
                {
                    $scope.posx++;
                }
            }

        });
</script>

var-app=angular.module(“游戏”,[]);
应用程序控制器(“controlematrix”,函数($scope)
{   
$scope.undo=[];
$scope.matriz=[2,2,2,2,2,2,2,2
,2,2,2,0,0,0,2
,2,3,0,0,0,0,2
,2,0,0,0,0,0,2                    
,2,3,0,0,2,0,2
,2,0,0,0,0,0,2  
,2,2,2,2,2,2,2];
$scope.posx=5;
$scope.posy=3;
$scope.testeshow=函数(atual){
返回(($scope.posx+$scope.posy*7)!=atual);
}
$scope.up=函数(){
如果($scope.matriz[$scope.posx+($scope.posy-1)*7]!=2)
{
$scope.posy--;
}
}
$scope.down=函数(){
如果($scope.matriz[$scope.posx+($scope.posy+1)*7]!=2)
{
$scope.posy++;
}
}
$scope.left=函数(){
if($scope.matriz[($scope.posx-1)+$scope.posy*7]!=2)
{
$scope.posx--;
}
}
$scope.right=函数(){
如果($scope.matriz[($scope.posx+1)+$scope.posy*7]!=2)
{
$scope.posx++;
}
}
});


向上的
向下
左边
正确的


调试后,posx和posy值似乎正在更新,但屏幕上的图像保持不变。我似乎找不到问题所在。如果有人能帮助我,我将不胜感激。

ng show
中删除
{}

<img ng-src="{{'tile' + x +'.png'}}"  alt="tile" 
     ng-show= "testeshow($index)"> 
<img ng-src="player.png"  alt="player" 
     ng-show= "!testeshow($index)"> 


ng show

<img ng-src="{{'tile' + x +'.png'}}"  alt="tile" 
     ng-show= "testeshow($index)"> 
<img ng-src="player.png"  alt="player" 
     ng-show= "!testeshow($index)"> 


ng show=“{{testeshow($index)}}”更改为
ng show=“testeshow($index)”
。需要一个表达式。

ng show=“{{testeshow($index)}”更改为
ng show=“testeshow($index)”
。需要一个表达式。

如果您的答案与其他答案不同,请写下答案以防万一。谢谢如果您的答案与其他答案不同,请写下答案以防万一。谢谢