2017-08-21 4 views
0

J'essaie d'inclure la bibliothèque js choisie dans mon projet où j'utilise une balise html. Son fonctionnement avec la liste de sélection simple, mais quand j'essaie de peupler la liste en utilisant js ng-repeat angulaire, son ne fonctionne pas. S'il vous plaît aidez-moi où j'ai mal tourné. ci-dessous est mon code.JS choisi ne fonctionne pas avec Angular JS Répétition

<html> 
 
<head> 
 
    <title></title> 
 
    <link rel="stylesheet" href="docsupport/style.css"> 
 
    <link rel="stylesheet" href="docsupport/prism.css"> 
 
    <link rel="stylesheet" href="chosen.css"> 
 
</head> 
 

 
<body ng-app="testapp" ng-controller = "testController"> 
 
    <select chosen class="chosen-select" ng-options = "cust.CustName for cust in customers"> 
 

 
    </select> 
 

 

 

 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.js" type="text/javascript"></script> 
 
     <script src="chosen.jquery.js" type="text/javascript"></script> 
 
     <script src="docsupport/prism.js" type="text/javascript" charset="utf-8"></script> 
 
     <script src="docsupport/init.js" type="text/javascript" charset="utf-8"></script> 
 

 
     <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"> </script> 
 

 
     <script type="text/javascript"> 
 
     var app = angular.module('testapp', []); 
 
     app.controller('testController',['$scope','$http', function($scope,$http)  
 
     { 
 
      $http.get("php/getCustomerList.php") 
 
      .then (function(response) 
 
      { 
 
       $scope.customers = response.data;    
 
      }); 
 
     }]); 
 
     </script> 
 
</body> 
 
</html>

+1

Je ne vois pas quelque chose que vous pour injecté 'chosen'. –

+0

vérifiez cette https://www.youtube.com/watch?v=8ozyXwLzFYs – nmanikiran

Répondre

1

Je pense que vous devez utiliser ng-model avec ng-options dans votre balise select. Essayez comme ci-dessous le code:

<select chosen class="chosen-select" ng-model="mySelectBox" ng-options = "cust.CustName for cust in customers"> 

Vous pouvez vérifier mon extrait de course ici. J'ai retiré votre appel api et entrer manuellement la valeur

<html> 
 
<head> 
 
    <title></title> 
 
    <link rel="stylesheet" href="docsupport/style.css"> 
 
    <link rel="stylesheet" href="docsupport/prism.css"> 
 
    <link rel="stylesheet" href="chosen.css"> 
 
</head> 
 

 
<body ng-app="testapp" ng-controller = "testController"> 
 
    <select chosen class="chosen-select" ng-model="mySelect" ng-options = "cust.CustName for cust in customers"> 
 

 
    </select> 
 

 

 

 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.js" type="text/javascript"></script> 
 
     <script src="chosen.jquery.js" type="text/javascript"></script> 
 
     <script src="docsupport/prism.js" type="text/javascript" charset="utf-8"></script> 
 
     <script src="docsupport/init.js" type="text/javascript" charset="utf-8"></script> 
 

 
     <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"> </script> 
 

 
     <script type="text/javascript"> 
 
     var app = angular.module('testapp', []); 
 
     app.controller('testController',['$scope','$http', function($scope,$http)  
 
     { 
 
       $scope.customers = [{'CustName':'Angular'},{'CustName':'JavaScript'},{'CustName':'Java'}];    
 
     }]); 
 
     </script> 
 
</body> 
 
</html>