angularjs - 重新加载或刷新正在 AngularJs 视图中呈现 Json 字符串
问题描述
我正在尝试在 angularJS 中上传 json 对象数组。第一次,单击链接时,工作正常。但刷新/重新加载页面后,视图消失并显示 JSON 字符串。请有人帮忙解决问题吗?
控制器:-
angular.module('app.failureNotify', []).controller('failureNotifyController',
function($scope, failureNotifyService) {
failureNotifyService.failureNotify().then(function(response) {
$scope.failureNotifyResponse = [];
$scope.failureNotifyResponse = response.data;
});
})
HTML:-
<div class="container" ng-controller="failureNotifyController">
<div class="row">
<div class="col-lg-8">
<h3>Controller list</h3>
</div>
</div>
<br /> <br /> <b>From Date</b> : <input type="text" name="from"
ng-model="from"> <br /> <br /> <b>To Date
</b>: <input type="text" name="to" ng-model="to"> <br />
<br />
<div class="row">
<div class="col-lg-8">
<table>
<tr>
<th>Account Number</th>
<th>Account Type</th>
</tr>
<tr
ng-repeat="failures in failureNotifyResponse">
<td>{{failures.accountNumber}}</td>
<td>{{failures.accountType }}</td>
</tr>
</table>
</div>
</div>
服务:-
angular
.module('app.services', [])
.service(
'failureNotifyService',
[
'$http',
function($http) {
this.failureNotify = function failureNotify()
{
return $http({
method : 'GET',
url : '/failureNotify',
})
}
} ])
解决方案
推荐阅读
- php - Reformat PHP MYSQL Array Result Multiple Levels Deep
- c# - 如何轻松地将域对象与相关实体进行比较,以便使用 EF Core 更新数据库?
- symfony - Nested variables in Symfony .env
- spring - How to use extension properties in Kotlin as constants?
- c# - TitleView 内的 Xamarin.Forms SearchBar 占用全宽
- vb.net - Parsing String into an Array (VB)
- npm - How to install gulp via NPM?
- java - 创建名为“emailController”的 bean 时出错
- c# - 检查 Gmail API 的特定用户帐户配额使用情况
- c - 错误:使用 GNU 复杂扩展时,在 'g_11' 之前需要 '='、','、';'、'asm' 或 '__attribute__'