我在json中调用数据但是我的数据没有收到,请你帮助我。
我是角度js的新人。
我的代码就是这个
Angular Code
var phonecatApp = angular.module('phonecatApp', []);
phonecatApp.controller('PhoneListCtrl', function ($scope, $http) {
$http.get('data.json').success(function(data) {
$scope.phones = data;
});
$scope.orderProp = 'age';
});
HTML代码
<!DOCTYPE html>
<html ng-app="phonecatApp">
<head>
<title>Hello i </title>
<link rel="stylesheet" href="style.css" />
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.25/angular.min.js"></script>
<script src="script.js"></script>
</head>
<body ng-controller="PhoneListCtrl">
<h1>Hello Plunker!</h1>
<div>Filter By <input type="text" ng-model="query" /> </div>
<div>Order By <select ng-model="orderPop">
<option> Chose One</option>
<option value="name">Name</option>
<option value="price">Price</option>
</select></div>
<ul>
<li ng-repeat="phone in phones | filter:query | orderBy:orderPop ">
{{phone.name}}
<p>{{phone.snippet}}</p>
<h2>Price {{phone.price | currency:"$"}}</h2></h2>
</li>
</ul>
<h4>Total No of Phone {{phones.length}}</h4>
</body>
</html>
答案 0 :(得分:1)
[{
"name": "Nokia X250",
"snippet": "nice application ",
"price": "260"
}, {
"name": "Moto G",
"snippet": "nice oprationg ",
"price": "252"
}]