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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Employee
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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.