Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript AngularJS:单选按钮不是';默认情况下未选中_Javascript_Angularjs - Fatal编程技术网

Javascript AngularJS:单选按钮不是';默认情况下未选中

Javascript AngularJS:单选按钮不是';默认情况下未选中,javascript,angularjs,Javascript,Angularjs,我正在用angular对一些单选按钮进行编码,但我无法使其中一个收音机显示为标记为默认值。 这是我的代码: <!-- language: lang-js --> //And this is the JavaSctipt: $scope.locationLookup = 1; $scope.updateDropdownValuesBreedingLocation = function() { // Change state for breeding

我正在用angular对一些单选按钮进行编码,但我无法使其中一个收音机显示为标记为默认值。 这是我的代码:

<!-- language: lang-js -->

    //And this is the JavaSctipt:

    $scope.locationLookup = 1;
    $scope.updateDropdownValuesBreedingLocation = function() { // Change state for breeding
      // location radio
      $scope.dropdownValues = ($scope.localData.useFavorites) ? $scope.variableDefinition.possibleValuesFavorite : $scope.variableDefinition.possibleValues;
      $scope.locationLookup = 1;
    };

    $scope.updateDropdownValuesAllLocation = function() { // Change state for all locations radio
      $scope.dropdownValues = ($scope.localData.useFavorites) ? $scope.variableDefinition.allFavoriteValues : $scope.variableDefinition.allValues;
      $scope.locationLookup = 2;
    };

<!-- language: lang-html -->
<!-- show-setting-form-element-new.html  -->
    <div ng-switch="widgetType">
    <div ng-switch-when="DROPDOWN">
        <input type="hidden" ui-select2="dropdownOptions" class="form-control select2" ng-model="valuecontainer[targetkey]" value-as-object="false" ng-change="changefunction()" ng-disabled="blockInput"/>
        <div ng-if="isLocation">
            <div class="possibleValuesDiv">
                <input type="radio" ng-disabled="blockInput"
                 ng-model="locationLookup" value=1 ng-change="updateDropdownValuesBreedingLocation()"> &nbsp;
                <span th:text="#{show.breeding.location}">Breeding locations</span> &nbsp;
                <input type="radio" ng-disabled="blockInput" 
                ng-model="locationLookup" value=2 ng-change="updateDropdownValuesAllLocation()"> &nbsp;
                <span th:text="#{show.all.location}">All locations types</span>
            </div>
            <div class="possibleValuesDiv">            
                <input type="checkbox" ng-model="localData.useFavorites" ng-checked="true" ng-change="updateDropdownValuesFavorites()"> &nbsp;
                <span th:text="#{show.favorite.location}">Show only favorite locations </span> &nbsp;
            </div>
        </div>
        <div ng-if="isBreedingMethod" class="possibleValuesDiv">
            <!--TODO : handle rendering of breeding method dropdowns for completeness-->
        </div>
    </div>
    <div ng-switch-when="NTEXT">
        <input type="text" ng-disabled="blockInput" valid-decimal="" class="form-control numeric-input" ng-model="valuecontainer[targetkey]" ng-change="changefunction()"/>
    </div>
    <div ng-switch-when="SLIDER">
        <input type="text" ng-disabled="blockInput" valid-decimal="" class="form-control numeric-input" ng-model="valuecontainer[targetkey]" ng-change="changefunction()"/>
    </div>
    <div ng-switch-when="CTEXT">
        <input type="text" ng-disabled="blockInput" class="form-control character-input" ng-model="valuecontainer[targetkey]" ng-change="changefunction()"/>
    </div>
    <div ng-switch-when="TEXTAREA">
        <textarea ng-disabled="blockInput" class="form-control character-input" rows="3" ng-model="valuecontainer[targetkey]" ng-change="changefunction()"/>
    </div>
    <div ng-switch-when="DATE">
        <input type="text" ng-disabled="blockInput" placeholder="yyyy-mm-dd" class="form-control date-input" ng-model="valuecontainer[targetkey]" jq-datepicker="true" with-image="true" image-src="/Fieldbook/static/img/calendar.png" ng-change="changefunction()"/>
    </div>
</div>

<!-- end snippet -->

//这是JavaSctipt:
$scope.locationLookup=1;
$scope.updateDropdownValuesBreedingLocation=function(){//更改繁殖状态
//定位无线电
$scope.dropdownValues=($scope.localData.useFavorites)?$scope.variableDefinition.PossibleValuesAvorite:$scope.variableDefinition.possibleValues;
$scope.locationLookup=1;
};
$scope.updateDropdownValuesAllLocation=function(){//更改所有位置的状态
$scope.dropdownValues=($scope.localData.useFavorites)?$scope.variableDefinition.allFavoriteValues:$scope.variableDefinition.allValues;
$scope.locationLookup=2;
};
繁殖地点
所有位置类型
仅显示最喜爱的位置
容器是这样的:

<!-- language: lang-html -->
    <section-container th:attr="heading=#{trial.managesettings.trial.environment.specify.level}">
        <div name="content">

            <table datatable="ng" dt-options="dtOptions" dt-instance="nested.dtInstance"
                   class="table table-curved table-condensed fbk-table-with-check fbk-datatable-environments" width="100%">
                <thead>
                <tr>
                    <th data-sortable="false" class="fbk-delete-link"></th>
                    <th data-sortable="false" th:text="#{trial.managesettings.trial.environment.label}">Environment</th>
                    <th data-sortable="false" ng-repeat="key in settings.managementDetails.keys()"
                        ng-hide="settings.managementDetails.val(key).hidden">
                        {{settings.managementDetails.val(key).variable.name}}</th>
                    <th data-sortable="false" ng-repeat="key in settings.trialConditionDetails.keys()">
                        {{settings.trialConditionDetails.val(key).variable.name}}</th>
                </tr>
                </thead>
                <tbody>
                <tr ng-repeat="environment in data.environments" ng-class="{even : $even, odd : $odd}">
                    <td class="fbk-delete-link fbk-table-delete-link">
                        <span ng-click="deleteEnvironment($index)" ng-show="data.noOfEnvironments > 1"
                              class="glyphicon glyphicon-minus-sign fbk-delete-sign">&nbsp;</span>
                    </td>
                    <td>{{environment.managementDetailValues[TRIAL_INSTANCE_NO_INDEX]}}</td>
                    <td ng-repeat="key in settings.managementDetails.keys()"
                        ng-hide="settings.managementDetails.val(key).hidden">
                        <show-setting-form-element-new ng-if="isLocation" settings="settings.managementDetails" targetkey="{{key}}"
                                                   valuecontainer="environment.managementDetailValues"
                                                       changefunction="onLocationChange({key: environment.managementDetailValues[key]})"></show-setting-form-element-new>
                        <show-setting-form-element-new ng-if="!isLocation" settings="settings.managementDetails" targetkey="{{key}}"
                                                       valuecontainer="environment.managementDetailValues"></show-setting-form-element-new></td>
                    <td ng-repeat="key in settings.trialConditionDetails.keys()">
                        <show-setting-form-element settings="settings.trialConditionDetails" targetkey="{{key}}"
                                                   valuecontainer="environment.trialDetailValues"></show-setting-form-element></td>
                </tr>
                </tbody>
            </table>
        </div>
    </section-container>
<!-- end snippet -->

环境
{{settings.managementDetails.val(key.variable.name}
{{settings.trialConditionDetails.val(key.variable.name}}
{{environment.managementDetailValues[TRIAL_INSTANCE_NO_INDEX]}
你能帮我吗?
最有趣的是,如果我把这些收音机放在桌子外面,它工作得很好!但不是在里面

这段代码似乎运行良好。我们能否获得您所面临问题的更多全貌和最小可复制示例?显示的代码应该可以工作,但是如果您涉及子作用域,则必须在ng model中使用对象。不要打破“在ng模型中始终有一个点”的黄金法则@charlietfl或切换到“controller as”语法。我很惊讶有多少人不知道/不使用“controller as”-我想问题是这段代码被放入了一个表标记中。除了这个表之外,我还使用了这个代码,它工作得很好。