【发布时间】:2019-05-27 04:13:05
【问题描述】:
我正在尝试在变量中分配组件的 html 内容,但它给出了错误。
import { Component, ViewChild, ElementRef } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import * as jsPDF from 'jspdf';
import Relatorio1Page from './relatorio1';
/**
* Generated class for the RelatoriosPage page.
*
* See https://ionicframework.com/docs/components/#navigation for more info on
* Ionic pages and navigation.
*/
@IonicPage()
@Component({
selector: 'page-relatorios',
templateUrl: 'relatorios.html',
})
export class RelatoriosPage {
constructor(public navCtrl: NavController, public navParams: NavParams) {
}
ionViewDidLoad() {
console.log('ionViewDidLoad RelatoriosPage');
}
@aViewChild('conteudo') conteudo: ElementRef;
public relatorio1(){
//the objective is to fill this variable with relatorio1Page inner html
let conteudo = Relatorio1Page.innerHTML;
}
}
页面之间的层次结构是
页面 -relatorio1 --Relatorio1Page.ts -relatorios --RelatoriosPage.ts
你能帮帮我吗?
【问题讨论】:
-
您的确切错误信息是什么?你什么时候打电话给
relatorio1()?你试过访问Relatorio1Page.nativeElement.innerHTML吗? -
请也分享 html 文件。你的问题不清楚
标签: angular typescript ionic3