html - angularJS loop to get json array
淡淡烟草味
淡淡烟草味 2017-05-15 16:59:22
0
1
616

I defined a variable in the jsp page:
<script type="text/javascript">


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

</script>
Then I want to use angularJS to loop through the json array. What should I do?

           <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>
淡淡烟草味
淡淡烟草味

reply all(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>

Since you are using angualr, do not use this method to obtain data

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template