我有以下代碼,我在其中使用ng-repeat與md-select。但它不工作,下拉顯示爲空白。如果我用div或html使用ng-repeat,請選擇它。下面請看,Angularjs ng-repeat與md-select和md-option不兼容
Angularform: -
<div class="col-xs-12 formClass" ng-controller="dropDownController">
<md-input-container class="formClass">
<label>Impacts</label>
<md-select name="impact" id="impact" ng-model="impact">
<md-option ng-repeat="impact in impacts.availableImpacts" value="{{impact.id}}">{{ impact.name }}
</md-option>
</md-select>
</md-input-container>
</div>
JS: -
app.controller('dropDownController', function ($scope) {
$scope.impacts = {
availableImpacts: [
{id: '1', name: 'name1' },
{ id: '2', name: 'name2' },
{ id: '3', name: 'name3' }
],
};
});
是我的另一角控制器和相同的指令表單運行良好。只有以上給出問題。我試着用上面的解決方案,但沒有工作:( – user2902067
試試這個,而不是在視圖中循環$ scope.availableimpacts = $ scope.impacts.availableImpacts [0]; ng-repeat =「impact in availableimpacts」看看它是否有任何區別 – Prasad
你有角材料在其他地方工作 – nweg