gpt4 book ai didi

mysql - 如何在 Angular JS 中从数据库获取信息到 div 或表单字段?

转载 作者:行者123 更新时间:2023-11-29 18:36:46 24 4
gpt4 key购买 nike

我希望我的所有信息都打印在表单字段或 angularjs 中的任何元素中。我已经尝试过但仍然没有显示。当用户单击编辑按钮时,我正在制作 CRUD 应用程序,然后应该弹出带有其信息的表单。我的表格是

<form  ng-controller="TablesPageCtrl">
<div class="form-group">
<label>Title</label>
<input type="text" class="form-control" ng-model="title" name="title">

</div>

<div class="form-group">
<label >Description</label>
<!-- <input type="text" ng-model ="description" name="description" -->
<textarea class="form-control" rows="5" ng-model ="form.description" name="description" placeholder="Enter Description"></textarea>
</div>
<div class="form-group">
<label >Duration</label>
<input type="text" class="form-control" ng-model = "form.duration" name="duration" placeholder="Enter Title">
</div>


<input type="submit" name="submit" value="update"></input>
</form>

我的 Controller 是

function TablesPageCtrl($scope, $filter, editableOptions, editableThemes, $window, $http, $uibModal, baProgressModal) {


//it is called from edit button which i didnt display on html code $scope.open = function(page, size,id,title) {
$scope.m = 'hello';
$uibModal.open({
animation: true,
templateUrl: page,
size: size,
resolve: {
items: function() {
return $scope.items;
}
}
});
$http.get("api/get-course/" + id).then(function(res) {
console.log(res.data.response.data);
$scope.lists = res.data.response.data;
var k = res.data.response.data.title;
alert(k);
$scope.test = { k};
// alert($scope.test)
});
// $scope.newObject = [{'items': id}];
// // form.title = id;

//
// console.log(id);
};
$scope.openProgressDialog = baProgressModal.open;

editableOptions.theme = 'bs3';
editableThemes['bs3'].submitTpl = '<button type="submit" class="btn btn-primary btn-with-icon"><i class="ion-checkmark-round"></i></button>';
editableThemes['bs3'].cancelTpl = '<button type="button" ng-click="$form.$cancel()" class="btn btn-default btn-with-icon"><i class="ion-close-round"></i></button>';

}

最佳答案

尝试:

$scope.title = res.data.title;

如果这不起作用,请尝试控制台仅注销 res 并查看返回数据的格式。

关于mysql - 如何在 Angular JS 中从数据库获取信息到 div 或表单字段?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45225192/

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