嗨,我在控制器中有下一个代码
app.controller('controller', function ($scope, $routeParams, $http) {
$http.get('db.json').success(function(data) {
$scope.phone = data;
});
这在json文件中
{
"title1" : "first title",
"title2" : "second title",
"title3" : "third title",
}
然后我尝试打印这样的数据
<h1>{{ db.title1 }}</h1>
但在浏览器中我什么也看不见。我做错了什么?
答案 0 :(得分:0)
"nameArr" : [
{
"title": "title",
"image": "images/img.png"
},
{
"title": "title",
"image": "images/img1.png"
},
{
"title": "title",
"image": "images/img2.png"
},
{
"title": "title",
"image": "images/img3.png"
}
]
和ng-repeat在html中像这样
<div class="item" ng-repeat="items in nameArr">
<img ng-src="{{ items.image }}">
<h1>{{ items.title }}</h1>
</div>
再次没有显示任何内容
答案 1 :(得分:0)
两件事:1)你在模板中引用的对象应该被声明,而不是在回调中,2)返回的数据将是一个字符串,你需要使用angular.fromJson或JSON.parse将其解析为一个对象。
bar_version_id
此外,在您的模板中,您无法访问此内部数据库,因为您将其放在手机上:
select f.foo_id, f.foo_version_id, f.foo_name, b.bar_id, b.bar_version_id, b.bar_name
FROM foo f, foo_bar fb, bar b
WHERE 1 = 1
AND f.foo_version_id = fb.foo_version_id (+)
AND fb.bar_version_id = b.bar_version_id (+)
ORDER BY f.foo_version_id, b.bar_version_id
;
foo_id | foo_version_id | foo_name | bar_id | bar_version_id | bar_name
1 | 1 | a | | | -- 1) independent foo
1 | 2 | a | 1 | 2 | b -- 2) link foo to first bar
1 | 3 | a | 1 | 4 | b -- 3) link second bar to foo
1 | 3 | a | 2 | 5 | b2 -- 3) link second bar to foo
1 | 4 | A | 1 | 6 | b -- 4) rename foo_name to A
1 | 4 | A | 2 | 7 | b2 -- 4) rename foo_name to A