I am trying to upgrade an old sharepoint project to the latest sharepoint framework. The client part is built with angular. As in spfx _spPageContextInfo is not available so I tired changing the code to


format but it does not work.

I have something like this in code

        $scope["proxyScriptTag"] = ["<script type='text/javascript' src='",
var appUrl = $window._spPageContextInfo.webServerRelativeUrl;

I tried changing it to

        $scope["proxyScriptTag"] = ["<script type='text/javascript' src='",
var appUrl = this.context.pageContext.web.absoluteUrl;

But I get the following error

Error: this.context is undefined

This is my first time working with SharePoint so I dont completely understand what is the issue. I think the context is not passed from the main ts file but I am not sure about it.

I am stuck on this problem so Any hint or idea would be helpful.

2 Answers 2


In your render method add something like


In the js file you can access the pageContext using something like


spfx uses typescript. in typescript this context doesnt behave like in javascript. The reason it doesnt is javascript is not strongly typed where typescript is strongly typed (typesafe).

you could utilize the flat arrow method:

$(document).ready((n, m) => yourmethod.run(n, m));

explained here:


you can find possible solutions and workarounds here to get the javascript version of this



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.