Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/14.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 带数组的角度和长岭dom树_Javascript_Arrays_Angularjs_Dom - Fatal编程技术网

Javascript 带数组的角度和长岭dom树

Javascript 带数组的角度和长岭dom树,javascript,arrays,angularjs,dom,Javascript,Arrays,Angularjs,Dom,我在angular中有html组件。模板是 <tr ng-repeat="item in documentList track by $index"> <td>{{item.TYPE}}</td> <td>{{item.DATE_CREATE}}</td> <td>

我在angular中有html组件。模板是

              <tr ng-repeat="item in documentList track by $index">
                <td>{{item.TYPE}}</td>
                <td>{{item.DATE_CREATE}}</td>
                <td>
                  <a type="button" class="btn btn-default" ng-click="delDocument(item)">Delete</a>
                </td>
              </tr>

{{item.TYPE}
{{item.DATE\u CREATE}
删除
方法文件(项)为

$scope.delDocument=函数(项){
if(确认('您真的要删除文档吗?')){
$.ajax(“/ajax/del_document.php”{
'method':'POST',
“数据”:{
“id”:item.id,
},
“成功”:函数(){
i=0;

而(i在执行操作后,尝试在success函数中使用
$scope.$apply()

 $scope.delDocument = function(item){
    if(confirm('Do you really want to delete document?')) {
      $.ajax('/ajax/del_document.php', {
        'method': 'POST',
        'data': {
          'id': item.ID,
        },
        'success': function(){
          i = 0;
          while(i<$scope.documentList.length) {
            if($scope.documentList[i].ID===item.ID) {
              $scope.documentList.slice(i, 1);
            }
            i++;
          }
          $scope.$apply();
          // or blow is a safe way to use $scope.$apply();
          // if($scope.$$phase){
            // $scope.$apply();
          // }
        }
      });
    }
  }
$scope.delDocument=函数(项){
if(确认('您真的要删除文档吗?')){
$.ajax(“/ajax/del_document.php”{
'method':'POST',
“数据”:{
“id”:item.id,
},
“成功”:函数(){
i=0;

而(i在执行操作后,尝试在success函数中使用
$scope.$apply()

 $scope.delDocument = function(item){
    if(confirm('Do you really want to delete document?')) {
      $.ajax('/ajax/del_document.php', {
        'method': 'POST',
        'data': {
          'id': item.ID,
        },
        'success': function(){
          i = 0;
          while(i<$scope.documentList.length) {
            if($scope.documentList[i].ID===item.ID) {
              $scope.documentList.slice(i, 1);
            }
            i++;
          }
          $scope.$apply();
          // or blow is a safe way to use $scope.$apply();
          // if($scope.$$phase){
            // $scope.$apply();
          // }
        }
      });
    }
  }
$scope.delDocument=函数(项){
if(确认('您真的要删除文档吗?')){
$.ajax(“/ajax/del_document.php”{
'method':'POST',
“数据”:{
“id”:item.id,
},
“成功”:函数(){
i=0;
while(iThanks,它可以工作(但是对于if($scope.$$phase)它不能工作)(!$scope.$$phase)
$scope.$apply()
是一种反模式。如果你以正确的方式使用
$scope.$apply
它就不需要它。谢谢,它可以工作(但是对于if($scope.$$phase)它不能工作)(!$scope.$$phase)
$scope.$apply()
是一种反模式。如果您以正确的方式使用
$scope.$apply,您根本不需要它。