【发布时间】:2017-07-03 13:44:02
【问题描述】:
已解决:两部分问题。正如 Veera 所指出的,模型没有正确存储在控制器中,主要问题与模块声明中的 Smart Table 注入有关。
之前我的下面的代码设法从 ng-options 的下拉菜单中生成一个列表。在进行了几次看似无关的更改后,它现在无法正常工作,我一生都无法弄清楚原因。
我知道很多人在 select 元素中遇到 ng-model 的问题,所以除非我犯了一个错误并且遗漏了一些语法,否则我认为这不是问题所在。
我正在尝试使用控制器中的数组中的“参考编号”填充列表。变量名称和数据中可能存在一些拼写错误,我已将它们与我在实际项目中使用的名称进行了更改。
var reqWebApp = angular.module('reqWebApp', ['smart-table']);
reqWebApp.controller('reqAppController', function reqAppController($scope) {
$scope.requests = [
{
ref : "000455",
status : "requested",
prod : "BLEH",
prodRef : "NAH8754",
prodSite : "BLEHTON"
}
{
ref : "003005",
status : "requested",
prod : "REDACTED",
prodRef : "NA78546",
prodSite : "REDVILLE"
}
];
});
<!DOCTYPE html>
<html lang="en" ng-app="reqWebbApp">
<head>
<meta charset="UTF-8">
<title>Pre-Acceptance</title>
<script src="../../bower_components/angular/angular.js"></script>
<script src="../../app.js"></script>
<style>
table { width: 90%; }
input { width: 95%; }
select { width: 100%; }
</style>
</head>
<body ng-controller="reqAppController">
<div style="display:inline">Pre-Accept Existing Request |
<table style="display:inline-table; width: 5%" border="1" >
<tr>
<th>
Ref No.
</th>
</tr>
<tr>
<th>
<select ng-model="references"
ng-options="request.ref for request in requests">
<option value=""></option>
</select>
</th>
</tr>
</table>
</div>
<button type="button" onclick="location.href='../home/homepage.html'">ACCEPT</button>
<button type="button" onclick="location.href='../home/homepage.html'">HOME</button>
</body>
</html>
感谢任何人花时间浏览它。 康纳
【问题讨论】:
标签: javascript angularjs web-applications