Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/394.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/3/arrays/12.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 角度js绑定具有全局作用域的局部数组_Javascript_Arrays_Angularjs_Multidimensional Array_Angularjs Bindings - Fatal编程技术网

Javascript 角度js绑定具有全局作用域的局部数组

Javascript 角度js绑定具有全局作用域的局部数组,javascript,arrays,angularjs,multidimensional-array,angularjs-bindings,Javascript,Arrays,Angularjs,Multidimensional Array,Angularjs Bindings,我有一个棱角形。只有2个输入框。我要坐飞机 输入框中的值,然后将其保存在数组中 然后问题开始了。 我想显示用Move$scope.dataShow=set.toString()包装的数组在函数内,并移除返回按钮: <input type="text" class="form-control" id="qus" placeholder="Enter Question" ng-model="qus"> <input type="text" class="form-control"

我有一个棱角形。只有2个输入框。我要坐飞机 输入框中的值,然后将其保存在数组中

然后问题开始了。
我想显示用
Move
$scope.dataShow=set.toString()包装的数组在函数内,并移除
返回按钮

<input type="text" class="form-control" id="qus" placeholder="Enter Question" ng-model="qus">
<input type="text" class="form-control" id="op1" placeholder="Option 1" ng-model="op1">
<label><input type="checkbox" ng-model="correct1">Correct</label>

<button class="form-control btn btn-primary" ng-click = "save()">Save</button>

<pre  ng-bind="dataShow"></pre>

Move
$scope.dataShow=set.toString()在函数内,并移除
返回按钮


非常感谢。现在它显示为字符串。但是我想显示为一个数组结构。如果你的意思是作为数组的JSON表示,将
set.toString
更改为
JSON.stringify(set)
在使用JSON.stringify后,第一个条目的输出看起来像[[“q1”、[“o1”,false]],第二个条目的输出是[[“q1”、[“o1”、false、“o2”、true]]、[“q2”、[“o1”、false,“o2”,true]]]但是我想要像这样[[“q1”[“o1”,false,]],[“q2”,[“o2”,true]]]怎么做???true/false是chk框的值。谢谢。现在它显示为字符串。但是我想显示为数组结构。如果你是指数组的JSON表示,请将
set.toString
更改为
JSON.stringify(set)
在第一个条目中使用JSON.stringify后,输出看起来像[[“q1”、[“o1”,false]],而第二个条目的输出是[[“q1”、[“o1”,false,“o2”,true]]、[“q2”、[“o1”,false,“o2”,true]],但我希望像这样[[“q1”、[“o1”,false,]]、[“q2”、[“o2”,true]]如何做到这一点????true/false是chk框的值。
var app = angular.module('qApp', []);
app.controller('qCtrl', function($scope) {
    var set = [];
    var op1 = [];
    $scope.save = function (){
        if($scope.correct1!==true){$scope.correct1=false;}      
        op1.push($scope.op1, $scope.correct1);
        var qus = [$scope.qus, op1];
        set.push(qus);
        console.log(qus);
        console.log(set);
        return set; 
    };
    $scope.dataShow = set.toString();
});
$scope.save = function () {
    var set = [];
    var op1 = [];

    if ($scope.correct1 !== true) {
        $scope.correct1 = false;
    }

    op1.push($scope.op1, $scope.correct1);

    var qus = [$scope.qus, op1];
    set.push(qus);
    console.log(qus);
    console.log(set);
    $scope.dataShow = set.toString();
};