使用从json

时间:2017-06-15 17:49:27

标签: javascript html angularjs json

我使用JavaScript,AngularJS,HTML和CSS(针对大学项目)在特定的前端编写Web应用程序,这就是我的问题:

我在我的js文件上加载了一个JSON(查询结果)为

var app = angular.module('myApp', ['angular.filter'])

app.controller('myCtrl', function($scope,$http) {

 $http.get('json/painting.json')
   .then(function(res){
        $scope.paintings = res.data;
    });

但它在我的应用程序中不起作用。

如果我以这种方式创建范围

$scope.paintings = [
  { 
     title: 'title1', 
     picture: 'img/397x300/01.jpg', 
     desc: 'Image01', 
     technique: 'acquerello', 
     dimension: '50x50',
     year: 1800, 
     artist: 'Picasso' 
  },
  { 
     title: 'title2', 
     picture: 'img/397x300/02.jpg', 
     desc: 'Image02', 
     technique: 'aereografia', 
     dimension: '70x50', 
     year: 1700, 
     artist: 'Paolone' 
  }
];

在我的HTML中我使用angular函数调用它来显示点击图片的弹出窗口

div class="work work-popup-trigger" ng-repeat="paints in paintings 

img class="pics" src="{{paints.picture}}"

第一个它不起作用,但我不能使用第二个,因为它在本地加载数据,我想使用JSON进行PostgreSQL交互。

我做错了什么?

0 个答案:

没有答案