Filter data from different controllers in Angular

Asked

Viewed 97 times

0

I’m having a hard time filtering the client systems within the select.

I’ll explain:

I have a client To that has the system 1 and 2, have the client B that has the system 3.

When selecting the client within the select, I want the select system pull only the system the client has contracted, if selecting the B I want only the system to appear 3 to select.

 <label for="sel1">Selecione um cliente</label>
    <select ng-required="true" class="form-control input-lg" ng-model="solicitacao.id_solicitacao_cliente" ng-controller="clienteController">  
      <option disabled></option>
      <option value="{{cliente.id_cliente}}" ng-repeat="cliente in cliDados | orderBy:'nomecli'">{{cliente.nomecli}}</option>
    </select>
    <label></label>
    <label for="sel1">Selecione um sistema</label>
    <select ng-required="true" class="form-control input-lg" ng-model="solicitacao.id_solicitacao_sistema" ng-controller="sistemaController">
      <option disabled></option>
      <option value="{{sistema.id_sistemas}}" ng-repeat="sistema in sisDados | orderBy:'nomesis'">{{sistema.nomesis }}</option>
    </select>

In other words, I have no idea how to pass the ID of the first select after selected.

  • A question: Why different controllers if they are 'related' to each other?

  • For each table of the bank I made a different controller, client has a controller just for him, system has another controller just for him, IE, he uses each controller to search the database information and fill the select with ng-repeat, because I don’t only use this information on this screen. They are not related to each other per se, they are independent controllers. The connection between them occurs through a third controller (controllerContract), where I inform which client X has the Y system.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.