一直试图让这个工作一天,最后想在这里发帖,看看是否有人已经解决了这个问题。我有一组复选框,我想更改下拉列表以填充复选框中的CHECKED。
因此,如果用户选择英语和西班牙语,我希望下拉列表仅显示这两个选项。
无论如何要在页面上这样做?我认为它必须是一个过滤器,但不确定它需要什么。谢谢!
$scope.languages = [
{value: "en", name: "English"},
{value: "es", name: "Spanish"},
{value: "zh", name: "Chinese"},
{value: "fr", name: "French"},
{value: "de", name: "German"},
{value: "jp", name: "Japanese"}
];
$scope.settings.custom.languages = [{Spanish: 1, English: 1, French: false, Chinese: false, Japanese: false}];
<label ng-repeat="language in languages" style="width:100px">
<input type="checkbox" ng-true-value="1" ng model="settings.custom.languages[language.name]" />{{language.name}}
</label>
<select
class="form-control"
ng-model="settings.custom.primaryLanguage"
ng-options="language.name for language in languages track by language.value">
</select>
答案 0 :(得分:0)
I decided to just do this:
$scope.settings.custom.languages = [
{value: "en", name: "English"},
{value: "es", name: "Spanish"},
{value: "zh", name: "Chinese"},
{value: "fr", name: "French"},
{value: "de", name: "German"},
{value: "jp", name: "Japanese"}
];
<label ng-repeat="(languageKey, language) in settings.custom.languages">
<input type="checkbox" ng-true-value="1" ng-model="language['enabled']" /> {{language.name}}
</label>
<select
class="form-control"
ng-model="settings.custom.defaultLanguage"
ng-options="language.name for language in settings.custom.languages | filter:{enabled:'1'} track by language.value">
</select>