Error Message TypeError: Can not read property 'length' of undefined

0

I'm trying to create an UPDATE in but the error message is always showing up:

TypeError: Cannot read property 'length' of undefined
  

app.controller.js "

$scope.editTodo = function(usuario){
    $scope.editedTodo = usuario;
    var toDoTemplate = '<input type="text" ng-model="editedTodo.nome"></br><input type="tel" ng-model="editedTodo.tel"></br><input type="emal" ng-model="editedTodo.email"></br>'
  var myPopup = $ionicPopup.show({
    template: toDoTemplate,
    title: 'Edite o contato',
    subTitle: 'modificando o contato',
    scope: $scope,
    buttons: [
      { text: 'Cancelar' },
      {
        text: '<b>Salvar</b>',
        type: 'button-positive',
        onTap: function(e) {
          if (!$scope.editedTodo.nome) {
            //don't allow the user to close unless he enters wifi password
            e.preventDefault();
          } else {
            for (var i = 0; i < $scope.usuarios.length; i++) {
                if($scope.usuarios[i].id === $scope.editedTodo.id){
                    $scope.usuarios[i] = $scope.editedTodo;
                    return;
                }
            };
          }
        }
      }
    ]
  });
}
  

app.service.js

    //UPDATE CADASTROS
    this.editTodo = function(data){
        return $http({
                method:"POST",
                url:Config.getUrl+"apiCadastro.php",
                data:data,                  
                headers:{
                    'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8;'
                }                   

        });
    };
  

perfil.html

<ion-view view-title="{{perfil}}">  
   <ion-nav-bar class="bar-balanced">   
         <ion-nav-back-button class="button-clear"></ion-nav-back-button>         
  </ion-nav-bar>


    <ion-content  ng-repeat="usuario in usuarioPerfil">
    </br>
  </br></br>
  </br>

        <div class="item item-text-wrap">
            <div class="item item-text-wrap">
            <div class="row row-center responsive-sm">                
                <div class="row row-center" style="text-align:center; padding: 0; margin:0;">    
                    <div class="col col-center" style="background-color: grey; color: #fff; width: 100%; height: 100px; padding-top: 15px !important">
                        <h1 class="light">{{usuario.nome}}</h1>
                        <h4 class="light" style=" color: #fff;">USUÁRIO</h4>
                    </div>
                </div>
            </div>
             </div>

    </br>
        <div class="item item-text-wrap">
            <div class="row row-center responsive-sm">            
                <div class="row row-center" style="text-align:center; padding: 0; margin:0;">    
                    <div class="col col-center" style="background-color: grey; color: #fff; height: 100px; padding-top: 15px !important">
                        <h1 class="light">{{usuario.tel}}</h1>
                        <p class="light" style=" color: #fff;">TELEFONE</p>
                     </div>
                 </div>
            </div>
        </div> 
    </br>

        <div class="item item-text-wrap">
            <div class="row row-center responsive-sm">            
                <div class="row row-center" style="text-align:center; padding: 0; margin:0;">    
                    <div class="col col-center" style="background-color: grey; color: #fff; height: 100px; padding-top: 15px !important">
                        <h1 class="light">{{usuario.email}}</h1>
                         <p class="light" style=" color: #fff;">E-MAIL</p>
                    </div>
                </div>
            </div>
        </div> </br> </br> 

        <a ion-button class="button button-full button-positive" ng-click="editTodo(usuario)">Editar</a>
    </br>



    </ion-content>
</ion-view>
    
asked by anonymous 17.01.2018 / 02:54

0 answers