使用Angularjs获取数组中的值并传值到html页面中显示出来
展开全部
<!DOCTYPE html><html ng-app="test"><head> <title>Freetrial</title></head><body ng-controller="FreetrialController"> <div class="xsy" ng-repeat="item in freetrial" ng-if="use('xy0001', 0, item)" id="xy0001"> <a href="{{item.sdcx()}}"><img src="">{{item.imgurl}}</a> <h1>{{item.goodstitle}} </h1> </div> <script type="text/javascript" src="../lib/angular.min.js"></script> <script> var app = angular.module('test', []); app.controller('FreetrialController', function($scope){ $scope.use = function(id, status, item){ var flag = false; if(!item || (id === item.goodsid && status === item.status)){ flag = true; } return flag; } $scope.freetrial = [ { goodsid:"xy0001", imgurl:"img/178.jpg", goodstitle:"好娃娃牌安全椅", quantity:"10份", cost:896, linkt:"sdcx()", status:0 }, { goodsid:"xy0002", imgurl:"img/178.jpg", goodstitle:"时尚包", quantity:"10份", cost:298, status:1 }, { goodsid:"xy0003", imgurl:"img/178.jpg", goodstitle:"好娃娃", quantity:"10份", cost:896, linkt:"sdcx()", status:0 } ] }); </script></body></html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询