我只有一个文本框
<input type="text" name="groupname" value="">
我想使用 angularjs 在上面的文本框中显示组名
app.controller('get_group_name', function($scope, $http) {
$http.get(site_url + 'admin/Usergroup_controller/get_available_user/1')
.then(function (response) {$scope.names = response.data.records;});
});
我正在获取类似 json 的数据
[{"groupname":"Bharat"}]
只有一条记录
如何在文本框中获取此数据。
最佳答案
<input type="text" name="groupname" ng-model = "names[0].groupname">
Ng-model 用于将数据从 Controller 绑定(bind)到 View 。我建议您访问 Angular 文档以更好地理解 Angularjs。
关于php - 如何在angularjs中显示单个数据库条目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36175031/