2015-12-21 56 views
1

我試圖讓用戶輸入YouTube網址,以便我可以在我的網站上顯示這些視頻,但我需要首先將Youtube列入白名單。我如何修復我的app.ts文件以適應打字稿?該文件看起來是這樣的:

.config(function ($sceDelegateProvider) { 
    $sceDelegateProvider.resourceUrlWhitelist([ 
     'self',     // trust all resources from the same origin 
     '*://www.youtube.com/**' // trust all resources from `www.youtube.com` 
    ]); 
}); 

的問題是,因爲我用我的打字原稿的.config不包含function關鍵字,我相信。我的配置目前看起來像這樣:

angular.module('MyApp', ['ngRoute', 'ngResource']).config(($routeProvider: ng.route.IRouteProvider, $locationProvider: ng.ILocationProvider, $sceDelegateProvider: ng.ISCEDelegateProvider) => { 
     $sceDelegateProvider.resourceUrlWhitelist([ 
      'self',     // trust all resources from the same origin 
      '*://www.youtube.com/**' // trust all resources from `www.youtube.com` 
     ]); 

我得到了相同的錯誤,該網址未被列入白名單。我是否需要將.config與該函數粘貼到不同的區域,或者有沒有辦法將Delegate提供程序包含在與我的路由提供程序和位置提供程序等位置相同的位置?

+0

這看起來像是對我而言的Angular方面的錯誤。 http://bit.ly/1mxkzDt這是TypeScript轉換爲JavaScript的方式,所以它不是'function'關鍵字。 –

+0

是的,看起來這不會起作用,你最終會在其他錯誤中出現。只是使用嵌入網址很容易,出於某種原因工作得很好。 – ScottVMeyers

回答

0

嘗試對web配置進行更改以允許此操作,但僅僅不起作用。必須找到另一種方式來使用YouTube視頻中的嵌入網址。

相關問題