![](/img/trans.png)
[英]What are the steps to implement Angular 2 in SharePoint 2010?
[英]Recovering current user on Sharepoint 2010, angular version 6
我正在嘗試在Sharepoint服務器內的Sharepoint應用程序上恢復當前用戶,它可以在我已經在這里測試過的基於AngularJS構建的舊應用程序中工作。
AngularJS應用上的代碼類似於以下代碼
var thisUser = $().SPServices.SPGetCurrentUser({
fieldName: "Title",
debug: false
});
現在,我嘗試在Angular 6中使用相同的代碼,但是當我嘗試使用此代碼構建項目時。 錯誤被指控
ERROR in src/app/pedido/pedido.component.ts(68,43): error TS2339:
Property 'SPGetCurrentUser' does not exist on type '(options?: any) => any'.
我已經添加SPServices的lib我angular.json,和我src/
文件夾中,我已經將該文件typings.d.ts
與下面的內容
interface JQuery {
SPServices(options?: any): any;
SPFilterNode(options?: any): any;
SPGetCurrentUser(options?: any): any;
}
使用此接口,我可以構建其他項目,只是這個試圖訪問SPServices
SPGetCurrentUser
屬性的項目不允許我構建我的項目,我該怎么辦才能解決這個問題?
在我的pedido.component.ts
我聲明了$
,如下例所示
declare var $: JQueryStatic;
它在所有其他項目中均有效,僅在這一項目中不起作用...
我正在使用sympmarc
這個lib
我的朋友在這里找到了解決此問題的方法,他將typings.d.ts
的內容typings.d.ts
為以下示例
interface JQuery {
//SPServices?(options?: any): any; // This line was removed
SPServices: any; // This line was added
// Now the property SPGetCurrentUser can be viewed in the SPServices
SPFilterNode(options?: any): any;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.