Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
dpoleon
Regular Visitor

powerbi-client 2.4.2

Hi,

 

I am trying to use the powerbi-client in an angular 4 application, I am getting to following error:

'getPages' does not exist on type 'Embed'.

 

Any help would be greatly appreciated....thanks in advance.

 

Here is my code:

______________________________________________________________________________

 

ngOnInit() {
this.reportId = 'dca89071-c679-4719-803b-xxxxxxxxxxxxxxx';
this.pbiService.getReport(this.reportId).subscribe(embedConfig => {
this.embedConfig = embedConfig;
// console.log(this.customerName);
const powerbi = new pbi.service.Service(pbi.factories.hpmFactory, pbi.factories.wpmpFactory, pbi.factories.routerFactory);
const models = pbi.models;

const filter = {
target: {
table: 'Customer',
column: 'Customer'
},
operator: 'Is',
values: [this.id]
};

const config = {
type: 'report',
tokenType: models.TokenType.Embed,
accessToken: this.embedConfig.EmbedToken.token,
embedUrl: this.embedConfig.EmbedUrl,
id: this.embedConfig.Id,
permissions: models.Permissions.All,
filters: [filter],
settings: {
filterPaneEnabled: false,
navContentPaneEnabled: false
}
};
// Even though an error is displayed, the parameter still works.
const report = powerbi.embed(this.reportContainer.nativeElement, config);
report.iframe.frameBorder = 'none';

report.on('loaded', function(event)
{
console.log('Ready...');

// Retrieve the report id.
const reportId = report.getId();

console.log('Report Id: ' + reportId);

report.getPages()
.then(function (pages) {
pages.forEach(function(page) {
const log = page.name + ' - ' + page.displayName;
console.log(log);
});
});
});
});
}
3 REPLIES 3
Eric_Zhang
Microsoft Employee
Microsoft Employee

@dpoleon

The getPages works with powerbi-client 2.4.2 in my test, what's going on if you test in below html?

<html>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js"></script>
<script src="powerbi.js"></script>

<script type="text/javascript">
window.onload = function () {
 // Read embed application token from Model
    var accessToken = "embeded token"; 
	
    // Read embed URL from Model
    var embedUrl = "embed url";

    // Read dashboard Id from Model
    var embedReportId = "reportid";

    // Get models. models contains enums that can be used.
    var models = window['powerbi-client'].models; 
	 
    var config = {
        type: 'report',
        tokenType: models.TokenType.Embed,
        accessToken: accessToken,
        embedUrl: embedUrl,
        id: embedReportId , 
		settings: {
        filterPaneEnabled: true	
    }		 
    };

    // Get a reference to the embedded dashboard HTML element
    var dashboardContainer = $('#reportContainer')[0] ;

    // Embed the dashboard and display it within the div container.
var reports = powerbi.embed(dashboardContainer, config);
	
reports.on('loaded', function(event)
{
var data = event.detail; 
         //console.log(JSON.stringify(data, null, ' '));
		 console.log('****************************************************');
		 console.log(reports.getPages());
		 console.log('****************************************************');
		 
})  
}
  
</script>  
<div id="reportContainer"></div> 
</html>  

Thank you for your reply,

 

I have implemented your suggested code but still getting nothing coming back for "reports.getPages()"...worryingly I'm not getting anything at all in the console window for the data variable even though the "filterPaneEnabled: true" is being applied.

 

Still getting "Property 'getPages' does not exist on type 'Embed'."

 

Is this because I am trying to use "powerbi-client" in an Angular 4 application?

 

Regards


@dpoleon wrote:

Thank you for your reply,

 

I have implemented your suggested code but still getting nothing coming back for "reports.getPages()"...worryingly I'm not getting anything at all in the console window for the data variable even though the "filterPaneEnabled: true" is being applied.

 

Still getting "Property 'getPages' does not exist on type 'Embed'."

 

Is this because I am trying to use "powerbi-client" in an Angular 4 application?

 

Regards


I don't know Angular. What's going on if you replace the token, embedurl etc in the HTML and open it in Chrome?

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.