I am currently integrating an Angular website into a Microsoft Teams tab. In order to perform certain computations, I need to retrieve the Team ID. To achieve this, I have recently added
npm install --save @microsoft/teams-js
.
Below is the code snippet that I used:
import { Component } from "@angular/core";
import * as microsoftTeams from "@microsoft/teams-js";
@Component({
selector: "app-root",
templateUrl: "./app.component.html",
styleUrls: ["./app.component.css"]
})
export class AppComponent {
title = "app";
teamID: string;
teamName: string;
groupID: string;
ngOnInit() {
microsoftTeams.initialize();
microsoftTeams.getContext(function(Context: microsoftTeams.Context) {
alert("getcontext call back function");
this.teamName = Context.teamName;
this.groupID = Context.groupId;
this.teamID = Context.teamId;
});
alert("after get context");
console.log("End");
}
}
The issue I am facing is that I am unable to fetch the microsoftTeams.Context
. Is there any additional step that needs to be taken? How should I tackle this problem correctly?