Ng-repeat : display only the first element, why?

Hi,

I have the following html code:

	<a ng-repeat="filter in imageFilters">
	<p>{{ name }}</p>
	<img id="{{id}}" class="img-filter" [src]="image">
    </a>

and the following .ts file.

@Component({
selector   : 'photo-filter',
templateUrl: 'photo-filter.html'

})
export class PhotoFilter {

image : any;

imagesFilters = [
		{
		name  : 'Normal',
		id    : 'normal'
		},
		{
		name  : 'Claredon',
        id    : 'claredon'
		},
		{
		name  : 'Gingham',
        id    : 'gingham'
		}	
];

constructor(private navParams: NavParams) {

this.image     = this.navParams.get('base64');

}

}

But only one image is displayed, and no name is displayed.

I’m a newbie, so can you let me know what the issue is ?

Thanks

Try it like this
<a *ngFor="let filter of imageFilters"> <p>{{ filter.name }}</p> <img id="{{filter.id}}" class="img-filter" [src]="image"> </a>
also you should consider wrapping your links in an ion-list .

Thanks,

But with this code, nothing is displayed :frowning:

Any suggestion ?

How about this
`
<ion-item *ngFor=“let filter of imageFilters”>

{{ filter.name }}

`

Thanks…

But nothing is displayed :frowning:

How is it possible ?

Weird , the second reply is a code snippet I use frequently , perhaps someone else could notice the problem and shed some light on the matter .

imageFilters != imagesFilters.

1 Like