2016-01-13 45 views
1

我有一個基於JSP + AngularJS的項目。選取列表(多選)組件不會更新數據。 BootStrap組件+ AngularJS

在我的jsp中,我有一個由引導模板提供的picklist組件。我從我的數據庫接收數據,這是我需要使用的公司的名稱,但我仍然無法將我選擇的那些數據「傳」到所選數據的一側。 查看圖片瞭解。任何信息都有幫助。謝謝。

enter image description here

我AngularJS控制器:

BoxApp.controller("CadastroCertificadoController", function($scope,  $http) { 

$scope.clientes = {}; 


$scope.iniciar = function() { 
$http.get('/boxmlV2/cadastrocertificado').success(function(response) { 
    $scope.clientes = response; 
}); 
}; 

$scope.iniciar(); 

}); 

我在我的JSP頁面組件:

       <div class="form-group"> 
            <label class="control-label col-md-3">Empresas:</label> 
            <div class="col-md-9"> 
            <select ng-model="certificadoIncluirAlterar.razaoSocial" multiple="multiple" class="multi-select" 
              id="my_multi_select1" name="my_multi_select1[]"> 
              <option ng-repeat="c in clientes" value="{{c.idCliente}}">{{c.razaoSocial}}</option> 
            </select> 

            </div> 
           </div> 

我的Java控制器(只是把從我的數據庫填充上表數據)

@Controller 
public class CadastroCertificadoController { 

@Autowired 
private ClienteService clienteService; 

@RequestMapping(value = "/cadastrocertificado", method = RequestMethod.GET) 
public ModelAndView iniciar(ModelMap modelMap) { 
    return new ModelAndView("cadastrocertificado"); 
} 

@RequestMapping(value="/cadastrocertificado", method=RequestMethod.GET, produces={"application/json"}) 
public @ResponseBody List<ClienteDTO> obterTodos(ModelMap modelMap){ 
    return clienteService.obterTodos(); 
} 


} 

回答

0

完成。

這是我的組件看起來像:

         <div class="form-group"> 
             <label class="control-label col-md-3">Empresas:</label> 
             <div class="col-md-9"> 

              <select multiple="multiple" class="multi-select" id="my_multi_select1" name="my_multi_select1[]"> 
               <option ng-repeat="c in clientes" value="{{c.idCliente}}" ng-click="atribuirUm($index, c)">{{c.razaoSocial}}</option> 
               <option selected ng-repeat="c2 in clientes2" value="{{c2.idCliente}}" ng-click="limparUm($index, c2)">{{c2.razaoSocial}}</option> 
              </select>          
             </div> 
            </div> 

這是我的AngularJS控制器:

BoxApp.controller("CadastroCertificadoController", function($scope, $http) { 

$scope.clientes = {}; 

$scope.iniciar = function() { 
    $http.get('/boxmlV2/cadastrocertificado').success(function(response) { 
     $scope.clientes = response; 
    }); 
}; 

$scope.iniciar(); 

$scope.clientes2 = []; 

$scope.atribuirUm = function(index, c) { 
    $scope.clientes2.push(c); 
    $scope.clientes.splice(index, 1) 
}  

$scope.limparUm = function(index, c2) { 
    $scope.clientes2.splice(index, 1) 
    $scope.clientes.push(c2); 
} 
}); 

enter image description here