我已經預定義的圖像,我想做一個微調,用戶可以選擇這些項目;但我也想爲自定義圖像選擇一個文件按鈕。angularjs連接下拉選擇文件
<div>
<select class="form-control" ng-model="inputQ.image">
<!-- show if there is no image -->
<option disabled value="{{ undefined }}"
ng-hide="inputQ.image && !isImageFromSpinner(inputQ.image)">
Nichts ausgewählt
</option>
<!-- show if there is a custom image -->
<option disabled
ng-show="inputQ.image && !isImageFromSpinner(inputQ.image)"
value="{{ isImageFromSpinner(inputQ.image) ? undefined : inputQ.image }}">
Benutzerdefiniertes Bild ausgewählt
</option>
<option ng-repeat="res in exerciseRessources.images"
value="{{res.blob}}" ng-disabled="res.disabled">
{{res.name}}
</option>
</select>
<br>
</div>
<div file-chooser ng-model="inputQ.image" accept="image/*">
<img class="input" ng-src="{{inputQ.image}}" alt="Beispiel"
ng-show="inputQ.image">
<br ng-show="inputQ.image">
<button class="btn btn-default" file-select>Bild auswählen...
</button>
<button class="btn btn-default" file-unselect>
<span class="glyphicon glyphicon-trash"></span>
</button>
</div>
我想在第二個選項中選擇處理自定義圖像,第一個是init。
但函數isImageFromSpinner
返回true或false。
$scope.isImageFromSpinner = function (model) {
$scope.exerciseRessources.images.forEach(function (img) {
if (img.blob && img.blob === model) {
$log.warn(model, true);
return true;
}
});
$log.warn(model, false);
return false;
};
如果元素在微調器中,則它應該爲true,否則爲false。不是true
,false
,true
,...
所以這也難怪,選擇選項不能正常工作。
有人知道,爲什麼我得到它或者真或假?
您不能在'
下工作真的非常感謝你輸入 – rala