Array vs Object, javascript / angularjs

0

Hello, I'm trying to work with angularjs and I have to do the following;

  • Make a table be populated with some object fields different
  • make a modal appear populated with different fields depending on the type of object that invokes modal.
  • The first part I was able to do, for example, I populate a table with an object of type "company" and another one of type "user" (are several of each), I can say what kind of object it is and some other fields of interest such as creation date etc. The second part I can do in part. I can make it according to the type of object it opens a different modal, one for the company and one for the user showing different fields for each one. Doubt: I can not get it populated with data from the object calling the modal function. How to do ????

    Relevant html code.

    <tr ng-repeat="alteracoes in vm.alteracoes">
                              <td>{{ alteracoes.userName }}</td>
                              <td>{{ alteracoes.role }}</td>
                              <td>{{ alteracoes.actionType }}</td>
                              <td>{{ alteracoes.userStatus }}</td>
                              <td>{{ alteracoes.entityType }}</td>
                              <!--<td>{{ alteracoes.link }}</td>-->
                              <td><button  class="btn btn-primary" ng-click="vm.verDetalhesEntidade(alteracoes.entityType)">Ver detalhes</button></td>
                              <td>{{ alteracoes.actionDate }}</td>
    </tr>
    

    And the controller;

         if(x == "Company"){
            vm.verDetalhesEntidadeCompany = function(){
              var modalInstance = $modal.open({
                scope: $scope,
                templateUrl :'caminhoDoModal1.view.html',
                resolve: {
                  alteracoesFound : function(){
                    $scope.alteracoesFound;
                  }
                }
              })
            }
            vm.verDetalhesEntidadeCompany();
          }else if(x == "usuario"){
          vm.verDetalhesEntidadeUser = function(){
            var modalInstance = $modal.open({
              scope: $scope,
              templateUrl :'caminhoDoModal2.view.html',
              resolve: {
                alteracoesFound : function(){
                  $scope.alteracoesFound;
                }
              }
            })
          }
          vm.verDetalhesEntidadeUser();
        }
      };
    

    My logic is as follows, I pass the type of entity that I am populating and I make a check in the controller to open the corresponding modal, but I am not getting the modal modal with the function data that invokes it.

    How to do this ?? Does anyone have any ideas that might help me?

        
    asked by anonymous 03.10.2018 / 22:10

    0 answers