Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.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_Angular Ui Router - Fatal编程技术网

Angularjs 如何发布ng重复对象数据?我试过这种方法,但不起作用

Angularjs 如何发布ng重复对象数据?我试过这种方法,但不起作用,angularjs,angular-ui-router,Angularjs,Angular Ui Router,如何发布ng重复对象数据?我试过这种方法,但不起作用 <body ng-controller="mainCtrl as MC"> <div> <div ng-repeat="(item,value) in MC.items"> {{item}} <input type="text" ng-model="value"/> </div> </div> <button ng-click="MC

如何发布ng重复对象数据?我试过这种方法,但不起作用

<body ng-controller="mainCtrl as MC">
<div>
    <div ng-repeat="(item,value) in MC.items">
        {{item}} <input type="text" ng-model="value"/>
    </div>
</div>
<button ng-click="MC.submitMe()">Save</button>
从:

在您的情况下,您缺少回调函数:

$http.post(url, mc.items).then(function successCallback(response) {
  alert('post data to ' + url + '\n' + JSON.stringify(mc.items));

}, function errorCallback(response) {
  alert('post failed');
});

{{item}}
拯救
如上所述更改您的ng型号

使用mc.items代替self.items
// Simple GET request example:
$http({
  method: 'GET',
  url: '/someUrl'
}).then(function successCallback(response) {
    // this callback will be called asynchronously
    // when the response is available
  }, function errorCallback(response) {
    // called asynchronously if an error occurs
    // or server returns response with an error status.
});
$http.post(url, mc.items).then(function successCallback(response) {
  alert('post data to ' + url + '\n' + JSON.stringify(mc.items));

}, function errorCallback(response) {
  alert('post failed');
});
<body ng-controller="mainCtrl as MC">
<div>
    <div ng-repeat="(item,value) in MC.items">
        {{item}} <input type="text" ng-model="MC.items[item]"/>
    </div>
</div>
<button ng-click="MC.submitMe()">Save</button>

Change your ng-model as above