json()からデフォルト値を取得するはずですが、選択した項目のデフォルト値を設定できません。 。私のコントローラで選択されたngモデルのデフォルト値を設定して変更を管理
私が選択したこの方法を設定している:
.controller('attributeFacetCtrl', function ($scope, tabsService, $location, contentService, attribute) {
$scope.attribute = attribute;
$scope.types = [{
val: 'terms'
}, {
val: 'continuous'
}];
$scope.selected = $scope.attribute.facet.data.type;
$scope.isTerms = false;
$scope.validateFrom = function() {
var chk = $scope.selected.val;
if (chk === 'terms') {
$scope.isTerms = true;
} else {
$scope.isTerms = false;
}
};
})
$ scope.attribute.facet.data.type = "用語"
そして、私のビューIでの結果この
<div class="form-group">
<label class="wk-field-label">
<i class="icon-asterisk wk-prefield wk-mandatory"></i>
Type
</span>
</label>
<select class="wk-field-input" ng-model="selected"
ng-options="typeValue as typeValue.val for typeValue in types"
ng-change="validateFrom()"
required></select>
</div>
<div ng-if="isTerms" ng-repeat="orders in attribute.facet.data.order">
<div>
<label class="wk-field-label">
<i class="icon-asterisk wk-prefield wk-mandatory"></i>
Order
</span>
</label>
</div>
</div>
'console.log($ scope.attribute.facet.data.type);の出力は何ですか? –
console.log outpus:terms – kyserslick