大家好我有以下JSON外部文件:
var app = angular.module('servicos', []);
app.controller('servicos_1', function($scope, $http){
$http.get("https://app-dot-contabilizei-jobs.appspot.com/rest/simulador/atividades").success(function(data){
$scope.cliente = data;
console.log(data);
});
});
正如你所看到的,在对象“对象”中有一个字符串,我是角色和面临问题的新手,用ng-repeat打印出来。
这是我的app.js
<!DOCTYPE html>
<html ng-app="servicos">
<head>
<meta charset="utf-8" />
<title>AngularJS display</title>
<link rel="stylesheet" href="style.css" />
<script data-require="angular.js@1.2.x" src="https://code.angularjs.org/1.2.28/angular.js" data-semver="1.2.28"></script>
<script src="js/app.js"></script>
</head>
<body ng-controller="servicos_1">
<div>
<span class="city">City</span><span>Rank</span>
</div>
<ul class="table" >
<li class="city-row" ng-repeat="value in cliente">
<span class="city-name">{{value.cod}}</span>
<span class="city-count">{{value.descricao}}</span>
</li>
</ul>
</body>
</html>
这里是我的index.html
{
if (Manager.SharedInstance.GetDatabase(DatabaseName) == null)
return;
IAuthenticator auth =
string.IsNullOrWhiteSpace(Username)
? null
: AuthenticatorFactory.CreateBasicAuthenticator(Username, Password);
pull = Manager.SharedInstance.GetDatabase(DatabaseName).CreatePullReplication(RemoteSyncUrl);
if(auth != null)
{
pull.Authenticator = auth;
}
push = Manager.SharedInstance.GetDatabase(DatabaseName).CreatePushReplication(RemoteSyncUrl);
if(auth != null)
{
push.Authenticator = auth;
}
pull.Continuous = true;
push.Continuous = true;
pull.Changed += ReplicationProgress;
push.Changed += ReplicationProgress;
//Set channels
List<string> channels = new List<string>();
channels.Add("channel");
// I had try to do that but not working,
// the documents created after that hadn't got the channels
pull.Channels = channels;
push.Channels = channels;
pull.Start();
push.Start();
我在这里看到了一些问题但没有一个对象在对象内。你能帮帮我们吗?
另一个问题是,还有另外两个外部jsons通过http.get请求。我可以创建另一个控制器,但如果我的身体控制器已经安装在我的第一个控制器上,我该如何管理呢?
谢谢你的时间!
答案 0 :(得分:0)
您必须将$scope.cliente
变量指向data.object
,而不仅仅是data
,
<ul class="table" >
<li class="city-row" ng-repeat="value in cliente.object">
<span class="city-name">{{value.cod}}</span>
<span class="city-count">{{value.descricao}}</span>
</li>
</ul>
希望这有帮助!
答案 1 :(得分:0)
实际上它在你的控制器中:
In [5]: numbers = ['666', '6', '123666', '12366', '66123', '666123', '666666', '6666', '6'*9, '66661236666', '12366664566786669']
In [8]: %timeit [devil(x) for x in numbers]
100000 loops, best of 3: 14 µs per loop
In [9]: %timeit [devil_fast(x) for x in numbers]
100000 loops, best of 3: 6.32 µs per loop
或者在您看来:
$scope.cliente = data.data.objects;