Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 48981

Can not read property 'substr' of undefined

$
0
0

I want to convert the value of date such as
2021-01-01 to 1 Januari 2021

I want to show it ini modal

pubdetil.ts

import { Component } from '@angular/core';
import { NavController, IonicPage, ViewController, NavParams, LoadingController } from 'ionic-angular';
import { Publikasi } from '../../providers/publikasi';

@IonicPage()
@Component({
  selector: 'page-pubDetil',
  templateUrl: 'pubDetil.html'
})

export class PubDetilPage {
  allPublication1:any =[];
  tanggal:string;
  bulan:string;
  tahun:string;  
  //listDomain1:any =[];
  //listDomain1:any[]=[];
  constructor(public navCtrl: NavController,  public navParams: NavParams, 
    public viewCtrl:ViewController, public publicationList1: Publikasi, public loadingController:LoadingController) {
      let allPublicationLoadingController = this.loadingController.create({
        content: ""
      });
      allPublicationLoadingController.present();
      this.publicationList1.getDetilPublikasi(this.navParams.get('pub_id'))
        .subscribe((publicationListData1:any) => {
          this.allPublication1= publicationListData1.data;
          allPublicationLoadingController.dismiss();
          })    
      console.log('ionViewDidLoad PubDetilPage');
  }

  ionViewDidLoad() {

  }
  
  goToLink(url: string){
    window.open(url, "_blank");
  }

  dismiss() {
    this.viewCtrl.dismiss();
  }

	getTanggalIndonesia(inputTanggal:string){
		this.tanggal=inputTanggal.substr(8);
		this.bulan=this.getBulanIndonesia(inputTanggal.substr(5,2));
		this.tahun=inputTanggal.substr(0,4);
		return this.tanggal+" "+this.bulan+" "+this.tahun;
	}

	public getBulanIndonesia(inputBulan:string){
		if (inputBulan=="01"){
			return "Januari";
		} else if (inputBulan=="02"){
			return "Februari";
		} else if (inputBulan=="03"){
			return "Maret";
		} else if (inputBulan=="04"){
			return "April";
		} else if (inputBulan=="05"){
			return "Mei";
		} else if (inputBulan=="06"){
			return "Juni";
		} else if (inputBulan=="07"){
			return "Juli";
		} else if (inputBulan=="08"){
			return "Agustus";
		} else if (inputBulan=="09"){
			return "September";
		} else if (inputBulan=="10"){
			return "Oktober";
		} else if (inputBulan=="11"){
			return "November";
		} 
		else if (inputBulan=="12"){
			return "Desember";
		}
	}

}

pubdetil.html

<ion-header>
  <ion-navbar>
    <ion-title>Detil Publikasi</ion-title>
      <ion-buttons end><button ion-button (click)="dismiss()">
        <ion-icon clear name="md-close-circle"></ion-icon>
      </button>
  </ion-buttons>
  </ion-navbar>
</ion-header>


<ion-content class="ion-padding">
  <ion-grid>
    <ion-card>
      <ion-row>
          <ion-col size="2">
            <ion-item>
              <ion-thumbnail>
                <ion-img [src]="allPublication1.cover"></ion-img>
              </ion-thumbnail>
            </ion-item>
          </ion-col>
          <ion-col>
          </ion-col>
          <ion-col size="10" style="font-weight: bold;">
            <span style="font-size: 1.5rem;">{{allPublication1.title}}</span>
            <ul style="padding:0;list-style: none;">
              <li style="font-size: 1.3rem;">No. Katalog : {{allPublication1.kat_no}}</li>
              <li style="font-size: 1.3rem;">Tanggal Rilis : {{ getTanggalIndonesia(allPublication1.rl_date) }}</li> 
              <li style="font-size: 1.3rem;">Size : {{allPublication1.size}}</li>
              <li style="font-size: 1.4rem;font-weight: bolder;">
                <a target="_blank" style="text-decoration: none;" href="{{allPublication1.pdf}}">
                  <ion-label color="primary">Unduh Publikasi</ion-label>
                </a>
              </li>
            </ul>
          </ion-col>
      </ion-row>
  </ion-card>
    <ion-row>
      <ion-col>
        <p style="font-size: 1.6rem;font-weight: bold;">Abstrak</p>
        <p style="text-align: justify;font-size: 1.5rem;">{{allPublication1.abstract}}</p>
      </ion-col>
    </ion-row>
  </ion-grid>
</ion-content>


data api

{
"status": "OK",
"request": {
"domain": "https://sumbar.bps.go.id",
"model": "publication",
"lang": "ind",
"id": "4f1ce24ad2e92d72c3cb2f25",
"time_access": "2021-06-06 00:56:10"
},
"data-availability": "available",
"data": {
"pub_id": "4f1ce24ad2e92d72c3cb2f25",
"title": "Pola Konsumsi Makanan Penduduk Provinsi Sumatera Barat 2020",
"kat_no": "3201009.13",
"pub_no": "13000.2126",
"issn": "",
"abstract": "Publikasi\r\npola konsumsi makanan penduduk Provinsi Sumatera Barat 2020 menggunakan data hasil Survei Sosial Ekonomi Nasional (Susenas)\r\nMaret 2019 dan Susenas Maret 2020. Data yang disajikan mencakup data\r\nkuantitas konsumsi makanan sebanyak 188 komoditi serta data konsumsi kalori dan\r\nprotein. Pada lampiran disajikan data tahun 2020 level kabupaten/kota karena\r\nsampelnya telah mencukupi untuk estimasi hingga tingkat kabupaten/kota.\r\n\r\n<br>",
"sch_date": "2021-06-03",
"rl_date": "2021-06-03",
"updt_date": null,
"cover": "https://sumbar.bps.go.id/publication/getImageCover.html?url=MjAyMS0wNi0wNiMjaHR0cHM6Ly9wb3J0YWxwdWJsaWthc2kuYnBzLmdvLmlkL2FwaS9nZXRLb3Zlci5waHA%2Fc2VsZWN0b3I9NGYxY2UyNGFkMmU5MmQ3MmMzY2IyZjI1",
"pdf": "https://sumbar.bps.go.id/publication/downloadapi.html?data=afu395ylWqQCv1tLL2S4Qzv1KSDs%2FwkERAkF8pZxtFQdDitvg%2FiBBF2wYaJiK%2FBWJo3Y8nx%2FqTLz1zWjFtyd5XsQPyMb9b79aE9hi%2FYSXiI%3D&tokenuser=",
"size": "5.13 MB"
}
}

I failed doing it, please help

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 48981

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>