Javascript 在AngularJS中UIRouter的多视图/嵌套状态下调用Httpget()
我刚接触AngularJS,现在面临多视图的问题。搜索了各种示例,但找不到解决方案。希望你能帮忙。 我在嵌套视图的控制器中有一个提交函数。当用户单击submit时,必须调用subt_click(),并且必须根据提供的日期创建url,并且应从该url调用数据并显示在表中Javascript 在AngularJS中UIRouter的多视图/嵌套状态下调用Httpget(),javascript,angularjs,url,angular-ui-router,http-get,Javascript,Angularjs,Url,Angular Ui Router,Http Get,我刚接触AngularJS,现在面临多视图的问题。搜索了各种示例,但找不到解决方案。希望你能帮忙。 我在嵌套视图的控制器中有一个提交函数。当用户单击submit时,必须调用subt_click(),并且必须根据提供的日期创建url,并且应从该url调用数据并显示在表中 <div ng-controller="MyController as ctrl"> <form class="form-horizontal"> <div class="form-gr
<div ng-controller="MyController as ctrl">
<form class="form-horizontal">
<div class="form-group">
<div class="col-sm-5">
<p class="input-group">
<input type="text" class="form-control" datetime-picker="yyyy-MM-dd HH:mm" ng-model="dates.date3" is-open="ctrl.open.date3" />
<span class="input-group-btn">
<button type="button" class="btn btn-default" ng-click="ctrl.openCalendar($event, 'date3')"><i class="fa fa-calendar"></i></button>
</span>
</p>
</div>
</div>
</form>
<a ui-sref=".submit" class="btn btn-info" ng-click="subt_click()">Submit</a>
</div>
tab-submit.html:
<table>
<thead>
<tr>
<th>ID</th>
<th>Name</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="x in condition">
<td>{{x.ID}}</td>
<td>{{x.Name}}</td>
</tr>
</tbody>
</table>
身份证件
名称
{{x.ID}
{{x.Name}
下面是检查代码的plunk:plunk
:
显示的表为空,不是url中的数据(我使用的url来自本地主机)。console和console上没有错误。log(响应)我可以从url中看到数组对象
我不知道哪里出了问题。如果有人能帮忙,我将非常感激 检查这个。我添加了一个控制器,一个用于获取数据的虚拟服务,并使用
resolve
中的服务将数据注入控制器。我尝试了您的plunk,但出现了两个控制台错误Datepicker指令:“ng model”值必须是日期对象
,get请求返回400个错误请求。假设您的本地代码正常工作,response
在您的成功回调中的值是多少?@Haymaker87:{“Table”:[{“ID”:6,“Name”:“Jack”},{“ID:7”,“Name”:“Jill”}]}好的,在这种情况下,我必须假设您的控制器没有正确映射到该视图。如果在routes块中取消注释//controller:“MyController”
,会发生什么情况?@Haymaker87:不更改其same我不确定为什么要添加$location.path('/date')控制器中的代码>。解释一下。$location
更改可能发生在您的httpget
调用完成之前。此插件有太多问题需要解决。这就是为什么我做了一个新的。但这就是我需要练习的代码。不能下流
<table>
<thead>
<tr>
<th>ID</th>
<th>Name</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="x in condition">
<td>{{x.ID}}</td>
<td>{{x.Name}}</td>
</tr>
</tbody>
</table>