2016-03-11 114 views
0
<p><b>Client Name</b></p> 
<div ng-repeat="client in clientList"> 
    <b>{{client.name}}</b> 
    <select value="Please select bot from list" ng-model='???' ng-options="b as b.name for b in listOfBots" |> 
    </select> 
</div> 
<button ng-click="(getBotSelection())">Select Bots</button> 

我沒有找到任何有關此特定實現的文章。 clientList是一個來自Excel文件告訴我更新客戶端的列表。我需要爲該客戶端運行一個bot,因此我在listOfBots中將ng-options設置爲bot.name。ngrepeat中ng選項的ngmodel

我發現的文章的問題是它們通常不會遍歷示例中的兩個單獨集合。我很難與這一個,請幫助。機器人的

表看起來是

for (var i = 0; i < listOfBotsArr.length; i++) { 
     listOfBotsObj.push({ 
     name: listOfBotsArr[i] 
     }); 
     $scope.$apply(); 
    } 

回答

0
<div ng-show="showBotList"> 
    <p>You must select which bots to run manually</p> 
    <p><b>Client Name</b></p> 
    <div ng-repeat="client in clientList"> 


    <b>{{client.name}}</b> 
    <select value="Please select bot from list" ng-model="bot" ng-options="b as b.name for b in listOfBots" ng-change="getSelectedBot(this.bot.name)" |> 
    </select> 
    </div> 
    <button ng-click="">Select Bots</button> 
</div> 

這是我的解決方案。通過ng-change和記錄它傳遞「this」,向我展示了我返回的對象,並且它有一個屬性bot.name,所以我們擁有它。