Created
February 8, 2017 13:37
-
-
Save ejke/333e6f1d7f4c7877c3b3d473e12caa73 to your computer and use it in GitHub Desktop.
Ionic2 dynamically change links with ngFor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ion-grid> | |
<ion-row> | |
<ion-col width-33 *ngFor="let info of infos"> | |
<div class="instructions" [navPush]="info.tap"> | |
<div> | |
<img src="assets/icons/{{info.icon}}.png" alt="Icon"> | |
</div> | |
<span>{{info.title}}</span> | |
</div> | |
</ion-col> | |
</ion-row> | |
</ion-grid> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component } from '@angular/core'; | |
import { NavController, NavParams } from 'ionic-angular'; | |
import { NumbersPage } from '../hadaabinumbrid/hadaabinumbrid'; | |
import { StatePage } from '../maakond/maakond'; | |
import { AboutPage } from '../naiskodukaitse/naiskodukaitse'; | |
@Component({ | |
selector: 'page-home', | |
templateUrl: 'home.html' | |
}) | |
export class HomePage { | |
infos: any; | |
constructor(public navCtrl: NavController, public navParams: NavParams) { | |
this.infos = [ | |
//first two are strings, last one object, that directs on click with navPush directly to necessary page | |
{title: 'Contact numbers', icon: 'numbers', tap: NumbersPage}, | |
{title: 'States represented', icon: 'states', tap: StatePage}, | |
{title: 'About us', icon: 'us', tap: AboutPage} | |
]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment