ardyhim

single.ts

Sep 4th, 2016
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { Component } from '@angular/core';
  2. import {Http} from '@angular/http';
  3. import { NavController, NavParams, ModalController } from 'ionic-angular';
  4. import { CommentPage } from '../comment/comment';
  5.  
  6. /*
  7.   Generated class for the SinglePage page.
  8.  
  9.   See http://ionicframework.com/docs/v2/components/#navigation for more info on
  10.   Ionic pages and navigation.
  11. */
  12. @Component({
  13.   templateUrl: 'build/pages/single/single.html',
  14. })
  15. export class SinglePage {
  16.   datas:any = [];
  17.   comments:any;
  18.   constructor(
  19.     private navCtrl: NavController,
  20.     params: NavParams,
  21.     private modalCtrl: ModalController,
  22.     private http: Http
  23.   ) {
  24.     this.http.get(params.data.url+"/?_embed").subscribe(data=>{
  25.       this.datas.push(data.json());
  26.  
  27.       this.http.get(data.json()._links.replies[0].href).subscribe(comment=>{
  28.         this.comments = comment.json()
  29.       });
  30.  
  31.     });
  32.   }
  33.  
  34.   openCommentPage(url){
  35.     let modal = this.modalCtrl.create(CommentPage,{
  36.       url:url
  37.     });
  38.     modal.present()
  39.   }
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment