html - angularJS 循环拿json数组
淡淡烟草味
淡淡烟草味 2017-05-15 16:59:22
0
1
584

我在jsp页面定义了一个变量:
<script type="text/javascript">


var wpmagazine=[{"title":"11","content":"coco"},
                {"title":"22","content":"nana"}];

</script>
然后在下面想要用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>
淡淡烟草味
淡淡烟草味

全部回复(1)
为情所困
<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,不要采用这种方式去获取数据

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板