Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.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
Angularjs ng型号范围输入类型在上载中不起作用_Angularjs_Input_Range - Fatal编程技术网

Angularjs ng型号范围输入类型在上载中不起作用

Angularjs ng型号范围输入类型在上载中不起作用,angularjs,input,range,Angularjs,Input,Range,使用ionic angularjs,尝试传递我的值以将其上载到服务器 Nots:上传正常,但仅使用默认值,如果我更改值,则仍使用默认值上传 我的HTML <section class="item" ng-repeat="survey in surveys.questions"> <p>{{survey.displayTitle}} <i class="fa fa-check" aria-hidden="true"></i></p&

使用ionic angularjs,尝试传递我的值以将其上载到服务器 Nots:上传正常,但仅使用默认值,如果我更改值,则仍使用默认值上传

我的HTML

<section class="item" ng-repeat="survey in surveys.questions">
      <p>{{survey.displayTitle}} <i class="fa fa-check" aria-hidden="true"></i></p>
      <div class="range">
        <i class="icon ion-sad"></i>
        <input type="range" min="{{min}}" max="{{max}}" name="range" id="{{survey.id}}"  ng-model='modelValue'>
        <span class="modelValue">{{modelValue}}<span></span></span>
        <i class="icon ion-happy"></i>
      </div>
    </section>

    <button class="button button-block button-assertive" ng-click="survey(modelValue)">
      <span ng-hide="loading">Submit <i class="fa fa-paper-plane" aria-hidden="true"></i></span>
      <span ng-show="loading">Please wait <i class="fa fa-spinner fa-spin"></i></span>
    </button>

作者注意:如果我添加到ng model='survey.modelValue'中,一切都正常工作,但是在前端,您会看到输入范围被禁用,用户必须移动它才能获得值。我想说的是,没有默认值添加它

谢谢大家,下面是我的简单答案

  you try to get model value like that

      var modelValue = document.getElementById(survey.id).value;


  i think helpful for you  



     // on click survey
        $scope.survey = function(){

         var modelValue = document.getElementById($scope.surveys.id).value;
            $scope.loading = true;
            // post survey question to database
            var obj = $scope.surveys.questions;
            var answers = [];
            var questionId = 1;
            angular.forEach(obj, function(value, key) {
                value.modelValue = modelValue;
                answers.push({"questionId" : questionId, "value" : value.modelValue});
                console.log({"questionId" : questionId, "value" : value.modelValue});
                questionId++;
            });

            $http.post(sharingDataService.getApiUrl() + '/app/survey/saveAnswers', {
                    "answers" : answers}
            ).then(function (data) {
                $state.transitionTo('thanks');
                console.log(answers);
            });


        }
<input type="range" min="{{min}}" max="{{max}}" name="range" id="{{survey.id}}" 
          ng-init="survey.modelValue=3" ng-model='survey.modelValue' >

只需添加ng init=“survey.modelValue=3”即可修复所有问题 OMG

将此添加到小提琴中。:)您必须维护一个本地数组以保持值的
范围
,因为ng repeat将创建其自己的作用域。我添加此值是因为我添加了它但不工作本地数组工作并保持值,但是用户界面中的值被清除,因此,用户必须移动范围以显示值,并提交我在控制台中获得的内容=referenceerror:modelValue未定义您在参数中传递modelValue的ID。不是因为这个错误,我添加了如下var modelValue=document.getElementById($scope.surveys.id).value,但是我得到了所有的值,所以我必须像这样添加$scope.survey=function(modelValue){….}尝试删除默认的模型值。然后检查一下。
<input type="range" min="{{min}}" max="{{max}}" name="range" id="{{survey.id}}" 
          ng-init="survey.modelValue=3" ng-model='survey.modelValue' >