//start news.js
import {Page, NavController, NavParams, Alert} from 'ionic/ionic';
import {Http} from 'angular2/http';
import {NewsDetailPage} from '../NewsDetailPage/newsdetail';
@Page({
templateUrl: 'build/pages/NewsPage/news.html'
})
export class NewsPage {
constructor(http:Http, nav:NavController, navParams: NavParams) {
this.nav = nav;
this.http = http;
this.newsData = null;
this.http.get('build/pages/NewsPage/data.json').subscribe(data => {
this.newsData= data.json();
},
err => {
let alert = Alert.create({
title: 'Network Error!',
subTitle: 'Cannot fetch the data from server!',
buttons: ['Ok']
});
this.nav.present(alert);
});
}
itemTapped(item) {
this.nav.push(NewsDetailPage, {
tit:item,
desc:item
});
}
}
//end of news.js
//start of newsdetail.js
import {Page,NavParams} from 'ionic/ionic';
@Page({
templateUrl: 'build/pages/NewsDetailPage/newsdetail.html'
})
export class NewsDetailPage {
constructor(navParams: NavParams) {
this.nav = nav;
this.title = navParams.get('tit');
this.description = navParams.get('desc');
}
}
//end newdetail.js
//start app.js
import {App, IonicApp, Platform} from 'ionic/ionic';
/*import {Http} from 'angular2/http';*/
import {NewsPage} from './pages/NewsPage/news';
import {MessagePage} from './pages/MessagePage/message';
import {MembersPage} from './pages/MembersPage/members';
import {GalleryPage} from './pages/GalleryPage/gallery';
import {EventsPage} from './pages/EventsPage/events';
import {YoutubePage} from './pages/YoutubePage/youtube';
import {ContactPage} from './pages/ContactPage/contact';
@App({
templateUrl: 'build/app.html',
config: {} // http://ionicframework.com/docs/v2/api/config/Config/
})
class MyApp {
constructor(app: IonicApp, platform: Platform) {
// set up our app
this.app = app;
this.platform = platform;
this.initializeApp();
// set our app's pages
this.pages = [
{ title: 'News', component: NewsPage},
{ title: 'Message', component: MessagePage },
{ title: 'Members', component: MembersPage },
{ title: 'Gallery', component: GalleryPage },
{ title: 'Events', component: EventsPage },
{ title: 'Youtube', component: YoutubePage },
{ title: 'Contact', component: ContactPage }
];
// make HelloIonicPage the root (or first) page
this.rootPage = NewsPage;
}
initializeApp() {
this.platform.ready().then(() => {
// The platform is now ready. Note: if this callback fails to fire, follow
// the Troubleshooting guide for a number of possible solutions:
//
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
//
// First, let's hide the keyboard accessory bar (only works natively) since
// that's a better default:
//
//
// For example, we might change the StatusBar color. This one below is
// good for light backgrounds and dark text;
if (window.StatusBar) {
window.StatusBar.styleDefault();
}
});
}
openPage(page) {
// close the menu when clicking a link from the menu
this.app.getComponent('leftMenu').close();
// navigate to the new page if it is not the current page
let nav = this.app.getComponent('nav');
nav.setRoot(page.component);
}
}