小编Vik*_*kas的帖子

检查ng-repeat中的项目是否已包含值

我有问题和答案的JSON字符串绑定在ng-repeat中,现在问题是我想在ng-repeat中显示一次问题和所有多个答案.这是我的数据.

{Answer:"White",AnswerID:967,answer_type:"RADIO",fullquestion:"Your Race",id:6}{Answer:"African American",AnswerID:968,answer_type:"RADIO",fullquestion:"Your Race",id:6}{Answer:"Asian",AnswerID:969,answer_type:"RADIO",fullquestion:"Your Race",id:6}
Run Code Online (Sandbox Code Playgroud)

我正在展示的观点

 <div ng-repeat="hrq in HrqQuestions">
            <div class="list card normal">
                <div class="item item-body item-divider">                    
                    <p ng-bind="hrq.fullquestion"></p>                       
                </div>
                <label class="item item-input" ng-show="hrq.answer_type=='FREETEXT'">
                    <input ng-model="hrq.Answer" name="name" type="text">
                </label>
                <div ng-if="hrq.answer_type=='RADIO'">
                    <ion-radio ng-click="selectedAnswer(hrq.AnswerID,hrq.Answer)" name="radio1" ng-value="hrq.AnswerID">{{hrq.Answer}}</ion-radio>
                </div>
            </div>
        </div>
Run Code Online (Sandbox Code Playgroud)

但这会多次将所有问题与答案联系起来

     Q.Your Race
           White Your Race
     Q.Your Race
           African American Your Race
     Q.Your Race
           Asian
Run Code Online (Sandbox Code Playgroud)

但我需要

     Q. Your Race
           White Your Race
           African American Your Race
           Asian
Run Code Online (Sandbox Code Playgroud)

如果有人能帮助我,我将非常感激

javascript angularjs angularjs-ng-repeat angular-ng-if

8
推荐指数
1
解决办法
1287
查看次数

使用角度js将数据发布到SOAP api

我试图将数据发布到soap api但无法这样做.我已经尝试了所有可能的方法但仍然在调用api时出错.

我的api是 - http://xyz.asmx?op = UserRegistration

并且它以xml格式排除数据

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <UserRegistration xmlns="http://Service/">
      <Usercreditional>string</Usercreditional>
    </UserRegistration>
  </soap:Body>
</soap:Envelope>
Run Code Online (Sandbox Code Playgroud)

我尝试过的事情 -

1>使用$ http.post

    var soapData = '<?xml version="1.0" encoding="utf-8"?>'+
    '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'+
    '<soap:Body>'+
    '<UserRegistration xmlns="http://Service/">'+
    '<Usercreditional>[{ \'DeviceUUID\': \'' + data.DeviceUUID + '\', ' +         
                      "\"DevicePushID\":\"" + data.DevicePushID + "\"}]" +
                    '</Usercreditional></UserRegistration></soap:Body></soap:Envelope>';

return $http({ 
            method: 'POST', 
            url: ' http://xyz.asmx?op=UserRegistration', 
            data : soapData, 
            headers : { "Content-Type" : 'application/xml'}
        });
Run Code Online (Sandbox Code Playgroud)

这给出错误"无法处理请求.--->根元素丢失"

2>使用SOAPClient

 var deferred = $q.defer(); 
 var soapParams …
Run Code Online (Sandbox Code Playgroud)

javascript soap web-services angularjs ionic-framework

7
推荐指数
1
解决办法
1202
查看次数