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提供程序包含在与我的路由提供程序和位置提供程序等位置相同的位置?
这看起来像是对我而言的Angular方面的错误。 http://bit.ly/1mxkzDt这是TypeScript转换为JavaScript的方式,所以它不是'function'关键字。 –
是的,看起来这不会起作用,你最终会在其他错误中出现。只是使用嵌入网址很容易,出于某种原因工作得很好。 – ScottVMeyers