gpt4 book ai didi

mysql - 使用 laravel4 框架的 AngularJS 中的 Splice 函数

转载 作者:行者123 更新时间:2023-11-29 20:27:22 25 4
gpt4 key购买 nike

我对在 AngularJS 中使用 splice 函数没有什么疑问。实际上我也想从查看页面中删除该行。数据正在从数据库中删除,但只有在刷新页面后效果才可见,并且我不想重新加载页面,我只想从查看页面中删除该行,也不重新加载页面。请帮忙解决这个问题。

AngularJS

$scope.deleteFunc = function(deleteId)
{

$http.get("http://localhost/crud/public/rectangle_delete_page/"+deleteId)
.then(function successCallback(response)
{
var del_obj = {};
del_obj.del_id = id;
$scope.select_rectangle.splice(del_obj);

console.log('successCallback');
console.log(response);
alert("Rectangle with id "+deleteId+", deleted..!");
},
function errorCallback(response)
{
console.log('errorCallback');
console.log(response);
});
};

View Page

<body ng-app="myApp" ng-controller="myCtrl">
<div class="container">
<h2>Rectangle dimension</h2><br/>
<table><td>
<div>
<table border=1>
<tr><td>Height:</td><td><input type="text" ng-model="lngth"><br/></td></tr>
<tr><td>Width:</td><td><input type="text" ng-model="brdth"><br/></td></tr>
<tr><td><input ng-click="insertFunc(lngth,brdth)" type="submit" value="Submit"></td></tr>
</table>
</div></td>

<td>
<div style="border:1px solid red; margin-top:10px; height:100px; width:100px">
<div style="height:{{lngtha}}px; width:{{brdtha}}px; max-width:100%; max-height:98%; margin-top:10px; background-color:yellow;"></div>
</div>
</td>


<td>
<div class="table-responsive">
<table class="table table-condensed" border=1>
<tr>
<th>ID</th>
<th>Length</th>
<th>Breadth</th>
<th>Draw Rectangle</th>
<th>Done</th>
<th>Delete</th>
</tr>
<tr ng-repeat="x in select_rectangle">
<td>{{x.id}}</td>
<td>{{x.length}}</td>
<td>{{x.breadth}}</td>
<td><input ng-click='show = true' type="submit" value="Draw" ng-model="myVar"></td>
<td width="100%" height="100%">
<div style="border:1px solid red; height:100px; width:100px">
<div style="height:{{x.length}}px; width:{{x.breadth}}px; max-width:100%; max-height:100%; background-color:yellow" ng-init='show = false' ng-show='show'/></div>
</div>
</td>
<td><input type="submit" value="Delete" ng-click="deleteFunc(x.id)"></td>
</tr>
</table>
</div>
</td>
</table>
</div>

Controller in laravel

public function rectangle_delete_function(Request $request)
{
$deleteId = $request->id;
return $rect_delete_query = DB::table('rectangle')->where('id', '=', $deleteId)->delete();
}

Route

Route::get('/rectangle_json_page', 'NewController@rectangle_json_function');

Route::get('rectangle_delete_page/{id}', 'NewController@rectangle_delete_function');

最佳答案

我刚刚像这样更新了 AngularJS

AngularJS

$scope.insertFunc = function(lngth,brdth) {

$scope.lngtha = lngth*0.375;
$scope.brdtha = brdth*0.375;

$http({
method : 'POST',
url : 'http://localhost/crud/public/insert_rectangle_dimension_page',
data : {lngth:$scope.lngth, brdth:$scope.brdth}
})
.then(function successCallback(response)
{
var obj = {};
obj.length = lngth;
obj.breadth = brdth;
$scope.select_rectangle.unshift(obj);
console.log(successCallback);
console.log(response);

},

function errorCallback(response)
{
console.log('errorCallback');
console.log(response);
});
}

但是我遇到了麻烦,我对此并不完全满意,我想从数据库中获取数据并显示在VIEW页面上,目前是直接插入,而不是从数据库中获取。请帮忙从数据库中获取。

关于mysql - 使用 laravel4 框架的 AngularJS 中的 Splice 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39226591/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com