Recently diving into the world of Angular and Ionic, I've come across some interesting API data:
[{"ID":"1","Title":"Maritime Safety","File_Name":"9c714531945ee24345f60e2105776e23.pdf","Created":"2018-11-07 17:36:55","Modified":"2018-11-07 17:36:55"}]
I want to integrate this data into my Ionic app using an API call. Here's a snippet of my Ionic app code:
import { Component } from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';
import { RestProvider } from '../../providers/rest/rest';
@Component({
templateUrl: 'modal-content.html',
})
export class NavigationDetailsPage {
item;
constructor(params: NavParams) {
this.item = params.data.item;
}
}
@Component({
templateUrl: 'contact.html',
})
export class ContactPage {
items = [];
pono: string;
inventorys: string[];
errorMessage: string;
constructor(public nav: NavController, public rest: RestProvider, public
navParams: NavParams) {
this.pono = navParams.get('data');
this.items = [
{
'title': 'Angular',
'description': 'A powerful Javascript framework for building single
page apps. Angular is open source, and maintained by Google.',
}
]
}
ionViewDidLoad() {
this.getInsights();
}
getInsights() {
this.rest.getInsights()
.subscribe(
inventorys => this.inventorys = inventorys,
error => this.errorMessage = <any>error);
}
openNavDetailsPage(item) {
this.nav.push(NavigationDetailsPage, { item: item });
}
}
I'm aiming to populate an array with my API data so that instead of the title being "Angular," it will display the actual document title and the description will contain the respective PDF file names. My ultimate goal is to create a document viewer where users can click on titles to directly open PDF files with a back button for navigation.
Your input would be highly appreciated.