Created
October 5, 2018 10:08
-
-
Save krishnaanaril/412001afccf2f74d1c840e1f7fb4b7fe to your computer and use it in GitHub Desktop.
Method to embed Power BI report
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
embedPowerBIReport() { | |
this.service.getReportEmbedToken().subscribe((res) => { | |
let response = res.json(); | |
let Token = response.EmbedToken; | |
const config = { | |
type: 'report', | |
tokenType: pbi.models.TokenType.Embed, | |
id: response.Id, | |
embedUrl: response.EmbedUrl, | |
accessToken: Token.token, | |
}; | |
// Grab the reference to the div HTML element that will host the report. | |
const reportsContainer = <HTMLElement>document.getElementById( | |
'embedReport' | |
); | |
const report = this.powerbi.embed( | |
reportsContainer, | |
config | |
); | |
// Report.off removes a given event handler if it exists. | |
report.off('loaded'); | |
// Report.on will add an event handler which prints to Log window. | |
report.on('loaded', (event)=>{ | |
console.log('loaded: '+event); | |
this.setTokenExpirationListener(Token.expiration, | |
2 /*minutes before expiration*/); | |
}) | |
report.off('pageChanged'); | |
report.on('pageChanged', e => { | |
console.log(e); | |
}); | |
report.on('error', function (event) { | |
console.log(event.detail); | |
report.off('error'); | |
}); | |
}, | |
(error) => { | |
console.log(error); | |
}) | |
} |
@aghilimc Whole project is not available online. I've done this for an organization.
where this.powerbi defined? please let me know
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, Where is the project of this file? i can not find full surec of project