我在jsp頁定義了一個變數:
var wpmagazine=[{"title":"11","content":"coco"},
{"title":"22","content":"nana"}];
然後在下面想要用angularJS 循環json數組,該怎麼做?
<p class="zxzz-cont" ng-repeat="">
<p class="zx-img"><a href="#"><img src="img/new_img1.jpg" /></a></p>
<p class="zx-text">
<p class="zx-tit"><a href="#">title</a></p>
<p class="zx-zy">content</p>
</p>
</p>
为情所困2017-05-15 17:01:22
<body ng-app="myApp">
<script type="text/javascript">
var wpmagazine = [
{"title": "11", "content": "coco"},
{"title": "22", "content": "nana"}
];
</script>
<p ng-controller="MyCtrl">
<p class="zxzz-cont" ng-repeat="item in wpmagazine">
<p class="zx-img">
<a href="#">
</a>
</p>
<p class="zx-text">
<p class="zx-tit"><a href="#">{{item.title}}</a></p>
<p class="zx-zy">{{item.content}}</p>
</p>
</p>
</p>
<script src="angular.js"></script>
<script>
var app = angular.module('myApp', []);
app.controller('MyCtrl', function ($scope) {
$scope.wpmagazine = wpmagazine;
});
</script>
</body>
既然使用了angualr,不要用這種方式去取得資料