获取重定向后空数组angularJs使用$ location.path [英] Getting null array after redirect using $location.path in angularJs

查看:155
本文介绍了获取重定向后空数组angularJs使用$ location.path的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是我的控制器code,其中我打电话的getResult方法: -

Here is my controller code where I'm calling getResult method:-

$scope.selectedAnswer = [];
$scope.correctAnswer = [];

$scope.result = function () {
    $(".optionlist").find("li").each(function () {
        if ($(this).attr('id') == 'true') {
            var label = $(this).parent('ul').attr('que-label');
            var value = $(this).find('input[type=checkbox]').attr('value');

            $scope.correctAnswer.push({ "label": label }, { "Option": value   });
            console.log(label);

        }
    });

$scope.getResult = function () {

$location.path("/reviewans");
}

下面是我的optionpage块: -

Here is my optionpage block :-

<div class="list-group list_top" data-toggle="items">

<ul class="left1 optionlist" data-value="{{$index+1}}" que-label="{{Questions.QuestionLabel}}">

<li class="list group-items alert alert-danger alert_template" style="display:none">
<a class="close" data-dismiss="alert" aria-label="close">&times;</a><span class="spantext"></span>
</li>

<li ng-repeat="Options in answerlist" ng-if="Questions.QuestionID == Options.QuestionID" id="{{Options.IsCorrectOption}}" ng-show="Options.QuestionID == Questions.QuestionID" ng-click="!IsAutoslide||AutoSlide(Options.QuestionID)">

<a href="#" class="list-group-item"><input type="checkbox" value="{{Options.QuestionOptionID}}" style="display:none">{{Options.OptionText}}</a>
</li>


</ul>

</div>
<div><a class="btn btn-default finish" style="display:none" ng-click="getResult()">Finish</a></div>

这是我的reviewans网页块: -

And here is my reviewans page block :-

<div class="tab-pane fade" id="messages" ng-init="result()">
                        <div class="all_ques_back col-md-12" ng-repeat="ans in correctAnswer">
                            <div class="col-xs-1 col-md-1"><i class="fa fa-times-circle fa-2x col_padd wrong_ans_font"></i></div>
                            <div class="col-xs-9 col-md-10 col_padd"><div class="all_ques" ng-repeat="(key, val) in ans">hello your ans {{val}}</div></div>
                            <div class="col-xs-1 col-md-1 col_padd"><i class="fa fa-angle-right right_arrow"></i></div>
                        </div><!-----end------>

                    </div>

问题是我使用location.path得到空结果在correctAnswer重定向后

problem is i'm getting null result in correctAnswer after redirection using location.path

推荐答案

我看不到你填入的'$ scope.correctAnswer地方?也许你想使用'$ scope.selectedAnswer呢?

I cannot see you populating '$scope.correctAnswer' anywhere? Maybe you want to use '$scope.selectedAnswer' instead?

这篇关于获取重定向后空数组angularJs使用$ location.path的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆