php - 如何在angularjs中显示单个数据库条目

标签 php mysql angularjs

我只有一个文本框

 <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。

fiddle :http://jsfiddle.net/Lvc0u55v/1452/

关于php - 如何在angularjs中显示单个数据库条目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36175031/

相关文章:

javascript - 如何在 Angular js $http 调用中显示超时错误?

javascript - TWBS Ratchet - 如何手动关闭模态?

javascript - 如何将 XMLHttpRequest 发送到特定的 php 函数?

java - 错误,json.JSONException : Value <br of type java. lang.String 无法转换为 JSONObject

php - 使用 JQuerys .post() 没有响应

php - sql1 获取名称和 sql2 获取印象,我需要按印象对名称进行排序

mysql - 使用 MySQL 计算两个表之间的每月用户分数?

mysql - 将 2 个不同的表连接到第三个表

mysql - 我可以在 MySQL 中使用 JSON_EXTRACT 进行不区分大小写的搜索吗?

javascript - 如何在 Ionic 中使用无限滚动时加载更多旋转器?