我试图在点击按钮时显示图像列表。我创建了图像数组,它们应该重复并显示在页面上。我不知道错误在哪里,这是我的代码。
<body ng-app="StarterApp" ng-controller="AppCtrl" layout="column" >
<md-content id="content"flex>
<h2>{{title}}</h2>
<p>{{content}}</p>
<img ng-src="{{image}}"/>
<div ng-repeat="pic in pics">
<img src="{{pic}}"/>
</div>
</md-content>
</body>
App.js
var app=angular.module('StarterApp', ['ngMaterial']);
app.controller('AppCtrl',['$scope', '$mdSidenav',function($scope,$mdSidenav) {
$scope.openGallery=function(){
$scope.title="Our work so far";
$scope.content="";
$scope.image="";
$scope.pictures=pics;
var pics=[
{
url: "svg/camera.png";
},{
url: "svg/email.png";
},{
url: "svg/person.png";
}
]};
答案 0 :(得分:1)
答案 1 :(得分:0)
在控制器中 -
var pics=[
{
url: "svg/camera.png";
},{
url: "svg/email.png";
},{
url: "svg/person.png";
}
$scope.pictures=pics;
HTML:
<div ng-repeat="pic in pictures">
<img src="{{pic.url}}"/>
</div>