为什么我的角列表显示不出来
Why wont my angular List show up?
我正在做一个Angular项目,首先使用Web API和实体框架代码。我有一个底部有一个表格的视图。加载视图时,它回调数据库以加载列表。我在不同的位置设置了断点,以确保我从数据库中获得正确的数据,并将其跟踪回角控制器。在控制器中,数据在那里,但它随后进入以太。我可以查看响应标头,它就在那里。我有点不知所措。我在WebApiConfig中放入了一些json序列化来处理骆驼/Pascal案例问题。下面是我的视图代码:
<div class=" nav">
<div class="span12">
<h3> Work with Dictionaries </h3>
<ul class="navbar-nav">
<li><a ui-sref-active="active" style="margin-right: 25px;" ui-sref="injuriesDict">Injuries Dictionary</a></li>
<li><a ui-sref-active="active" ui-sref="excercisesDict">Excercise Dictionary</a></li>
</ul>
</div>
</div>
<h3>Patient Entry Form</h3>
<ul class="navbar-nav">
<li><a ui-sref-active="active" ui-sref="patientEntry">Patient Entry</a></li>
</ul>
<div class="container span12">
<div class="row">
<h1>Patient Search</h1>
<form class="form-search horizontal-form" method="POST">
<label for="lastName">LastName</label>
<input type="text" class="input-medium" style="margin-bottom: 10px;" id="lastName" name="name">
<br>
<label for="ssn">SSN</label>
<input type="text" class="input-medium" style="margin-left: 40px; margin-bottom: 10px" id="ssn" name="ssn">
<br>
<label for="mrn">MRN</label>
<input type="text" class="input-medium" style="margin-left: 32px; margin-bottom: 20px;" id="mrn" name="mrn">
<br>
<button type="button" class="btn btn-default" ng-click="vm.patientSearch();">Search</button>
</form>
</div>
</div>
<div class="container">
<div class="row">
<h2>Patient Results</h2>
<div ng-controller=" patientSearch as vm">
<table style="border: 1px;" class="span8">
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>MRN #</th>
<th>SSN</th>
<th>Injury Type</th>
<th>Injury Date</th>
</tr>
<tr>
<th>{{vm.firstName}}</th>
<th>{{vm.lastName}}</th>
<th>{{vm.mrn}}</th>
<th>{{vm.ssn}}</th>
<th>{{vm.injuryType}}</th>
<th>{{vm.injuryDate | date}}</th>
</tr>
</table>
</div>
</div>
</div>
这是我的控制器代码
(function() {
'use strict';
angular.module('app')
.controller('patientSearch', ["patientResource", patientSearch]);
function patientSearch(patientResouce) {
var vm = this;
patientResouce.query(function(data) {
vm.patients = data;
});
}
}());
I just don't see why it is not loading the table, does anybody see anything drastically wrong with my code?
您可能想要这样的内容:
<table style="border: 1px;" class="span8">
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>MRN #</th>
<th>SSN</th>
<th>Injury Type</th>
<th>Injury Date</th>
</tr>
<tr ng-repeat="patient in patients">
<th>{{patient.firstName}}</th>
<th>{{patient.lastName}}</th>
<th>{{patient.mrn}}</th>
<th>{{patient.ssn}}</th>
<th>{{patient.injuryType}}</th>
<th>{{patient.injuryDate | date}}</th>
</tr>
</table>
假设您希望将患者列表作为表内容,每个患者记录一行。
您需要使用controllerAs语法(vm.patients):
<tr ng-repeat="patient in vm.patients">
<th>{{patient.firstName}}</th>
<th>{{patient.lastName}}</th>
<th>{{patient.mrn}}</th>
<th>{{patient.ssn}}</th>
<th>{{patient.injuryType}}</th>
<th>{{patient.injuryDate | date}}</th>
</tr>
相关文章:
- 我希望只有在我滚动页面后才能显示我的返回页首图标
- 希望在单击href链接时显示我的广告
- 我想隐藏/显示我的SVG元素,同时在anguarJS中使用它
- 为什么我的html弹出窗口显示我的函数的文本,而不是运行它们
- 我怎样才能显示我的子数组解唱 Angular js
- 在谷歌地图上显示我的位置
- 如何在谷歌地图上显示我的数据库地址,不带lat和long
- 为什么浏览器不't显示我的日历
- ng-repeat / ng-bind 不会显示我的数据
- 我无法使用 d3.js 在每月数据中显示我的 x 轴
- 为什么我的 onclick 事件不显示我的 JSON 文件
- Firebug 不显示我的 JavaScript?找不到错误
- 我只想在警报中打印数据,但每当它提醒我 [对象对象] 但我希望它会显示我的表数据行
- var.push 并在 HTML 页面中显示我的新临时信息
- 为什么IE无法正确显示我的HttpHandler Web应用程序中的特殊符号
- 谷歌地图没有显示我的位置
- 如何使用 Jquery 在段落中以纯文本形式显示我的数据,该段落以 JSON 文本包装
- JavaScript代码很好,但网页预览只显示我的html工作
- 谷歌地图API v3:我在热图上显示我的数据时遇到问题
- 摘要循环显示我的数组没有变化(视图不会刷新)