Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/13.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
Arrays 在AngularJS中的字符串中插入数组结构_Arrays_Angularjs - Fatal编程技术网

Arrays 在AngularJS中的字符串中插入数组结构

Arrays 在AngularJS中的字符串中插入数组结构,arrays,angularjs,Arrays,Angularjs,如何将对象的数组结构作为字符串插入数据库 $scope.lists = [ { label: "Parcerias Principais", allowedTypes: ['p1'], class: "b1", people: [] }, { label: "Atividades Principais", allowedTypes: ['p2'], class:

如何将对象的数组结构作为字符串插入数据库

$scope.lists = [
    {
        label: "Parcerias Principais",
        allowedTypes: ['p1'],
        class: "b1",
        people: []
    },
    {
        label: "Atividades Principais",
        allowedTypes: ['p2'],
        class: "b2",
        people: []
    }
];


$scope.salvar = function(){ 
    $http.post('link', { 
        aluno: 1, 
        tarefa: $scope.lists, 
        data: new Date(), 
        dataultima: new Date(), 
        curso: 82}).then(function(resultado){ 
            $ret = resultado.data; 
            console.log($ret); 
    }); 
}
预期成果:


我想以这种方式将我的direct数组插入SQLSERVER数据库。

尝试使用JSON.stringify,如下所示:

$scope.salvar = function(){ 
    $http.post('link', { 
        aluno: 1, 
        tarefa: JSON.stringify($scope.lists), 
        data: new Date(), 
        dataultima: new Date(), 
        curso: 82}).then(function(resultado){ 
            $ret = resultado.data; 
            console.log($ret); 
    }); 
}

尝试使用JSON.stringify,如下所示:

$scope.salvar = function(){ 
    $http.post('link', { 
        aluno: 1, 
        tarefa: JSON.stringify($scope.lists), 
        data: new Date(), 
        dataultima: new Date(), 
        curso: 82}).then(function(resultado){ 
            $ret = resultado.data; 
            console.log($ret); 
    }); 
}

你的php和ajax调用在哪里?我把$http调用放进去了question@AdrielOliveira还有php?我只想把整个数组作为字符串发送…php和ajax调用在哪里?我把$http调用放进去了question@AdrielOliveiraphp呢?我只想把整个数组作为字符串发送……欢迎,@adrieliveira。我已经投票赞成你的问题+1。现在不是-1:)欢迎,@adrielivera。我已经投票赞成你的问题+1。现在它不是-1:)