【问题标题】:ng-repeat is not showing all values of the array when i select a particular option当我选择特定选项时,ng-repeat 未显示数组的所有值
【发布时间】:2023-03-15 12:34:01
【问题描述】:

我正在使用 ui-select-matchng-repeat

我有一个包含五个值的数组,如下所示occurrence。 我的代码工作正常,除了当我选择 first 选项时 all 从下拉列表中消失,之后如果我选择“第二个” 比“全部”显示在下拉选项中。 这是我的html代码

 <div class="col-xs-12 col-sm-6 col-md-6 col-lg-3" id="sdlPrdAddS_sdlAvlF_awkC">
        <div class="formElement" id="sdlPrdAddS_sdlAvlF_awk">
            <p id="sdlPrdAddS_sdlAvlF_awkL">
                <label>{{'healthcareService.addSchedule.availability.occurrence' | translate}}</label><span class="red">*</span></p>
            <ui-select multiple name="occurrenceInMonth" data-ng-model="scheduleFormObj.daysOfWeekInput.occurrence" id="sS_adR_occureence" on-select="removeExtraFields()" ui-select-required="true">
                <ui-select-match placeholder="{{'healthcareService.addSchedule.scheduleDetails.select' | translate}}">
                    {{$item}}
                </ui-select-match>{{occurrence}}
                <ui-select-choices repeat="occurrence in scheduleStaticObjs.occurrence">
                    <div ng-bind-html="occurrence"></div>
                </ui-select-choices>
            </ui-select>
        </div>
   </div>

我的对象是这样的:

scheduleStaticObjs.occurrence =
["All","First","Second","Third","Fourth","Fifth"]

【问题讨论】:

标签: angularjs angularjs-ng-repeat ui-select


【解决方案1】:

我认为您可能想检查 on-select="removeExtraField()" 中发生的情况,因为这可能是问题

查看this jsfiddle 以查看您可能需要的工作版本

<div ng-app="test">
  <div ng-controller="MainCtrl">
    <ui-select multiple ng-model="test" theme="bootstrap">
      <ui-select-match allow-clear="true" placeholder="Pick one...">
        {{$item}}
      </ui-select-match>
      <ui-select-choices repeat="val in test_values">
        <span ng-bind="val"></span>
      </ui-select-choices>
    </ui-select>
  </div>
</div>

下面的JS:

angular.module('test', ['ui.select']);

angular
  .module('test')
  .controller('MainCtrl', function($scope) {
    $scope.test_values = ["All", "First", "Second", "Third", "Fourth", "Fifth"]
  });

希望对你有帮助

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-04-22
    • 2019-02-18
    • 1970-01-01
    • 1970-01-01
    • 2014-09-27
    • 2021-04-02
    • 2017-08-22
    相关资源
    最近更新 更多