0
我有一個我想重構的ng-switch語句。它看起來像這樣:具有共享選項的ng-switch
<div ng-switch on="property.type">
<input type="text" ng-switch-when="string" ng-model="property.value" placeholder="Property value">
<select ng-switch-when="bool" ng-model="property.value" ng-options="value for value in [true,false]" placeholder="Property value"></select>
<input type="number" ng-switch-when="int" ng-model="property.value" placeholder="Property value">
<input type="text" ng-switch-default ng-model="property.value" placeholder="Property value">
</div>
可以注意到ng-model
和placeholder
選項是相同的所有情況。我的問題是:我可以重構這個以某種方式讓這些選項只寫一次嗎?
謝謝!烏里