【发布时间】:2019-01-09 01:47:57
【问题描述】:
在我的应用程序中,我可以使用 console.log 验证是否选择了正确的信息,但尝试在表单文本框中显示此信息不起作用。谁能告诉我我做错了什么?
这是我视图的 HTML。
<table class="table table-stripped table-hover">
<thead>
<tr>
<th>ID</th>
<th>Title</th>
</tr>
</thead>
<tbody>
<tr data-ng-repeat="organization in organizations | filter:search" data-ng-click="navToEdit($index)">
<td>{{organization.Id}}</td>
<td>{{organization.Title}}</td>
</tr>
</tbody>
</table>
这是单击该列表中的项目将您带到的内容。
<div class="form-group">
<label for="txtTitle">Title:</label>
<input type="text" type="text" id="txtTitle" class="form-control" data-ng-model="organization.Title" />
</div>
这是我的控制器。
app.controller("organizationsCtrl", ["$scope", "$location", "$routeParams", "spService",
function ($scope, $location, $routeParams, spService) {
var listTitle = "Organizations";
$scope.editing = false;
//example populating Organizations
spService.getRecords(listTitle, "?$select=ID,Title").then(function (result) {
$scope.organizations = result;
});
$scope.navToAdd = function() {
$location.path("/organizations/add");
}
$scope.navToEdit = function(index) {
$scope.organization = $scope.organizations[index];
$location.path("/organizations/" + index);
console.log($scope.organization.Title);
}
}
]);
$scope.navToEdit 确实输出了正确的组织,但 txtTitle 的文本框没有显示任何内容。
请帮忙!!
【问题讨论】:
标签: javascript jquery html angularjs