Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 使用$sceDelegateProvider在Typescript中将Youtube列入白名单_Angularjs_Typescript - Fatal编程技术网

Angularjs 使用$sceDelegateProvider在Typescript中将Youtube列入白名单

Angularjs 使用$sceDelegateProvider在Typescript中将Youtube列入白名单,angularjs,typescript,Angularjs,Typescript,我正试图允许用户输入Youtube的URL,以便在我的网站上显示视频,但我需要先将Youtube列入白名单。如何在typescript中修复app.ts文件以适应此情况?文档如下所示: .config(function ($sceDelegateProvider) { $sceDelegateProvider.resourceUrlWhitelist([ 'self', // trust all resources from the

我正试图允许用户输入Youtube的URL,以便在我的网站上显示视频,但我需要先将Youtube列入白名单。如何在typescript中修复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`
    ]);
});
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不包含function关键字,我相信这是因为我使用的是typescript。我的配置当前如下所示:

.config(function ($sceDelegateProvider) {
    $sceDelegateProvider.resourceUrlWhitelist([
        'self',                    // trust all resources from the same origin
        '*://www.youtube.com/**'   // trust all resources from `www.youtube.com`
    ]);
});
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`
        ]);

我得到了相同的错误,url没有被列入白名单。我是否需要在不同的区域粘贴带有该函数的.config,或者是否有方法将代理提供程序包括在与我的路由提供程序和位置提供程序相同的位置,等等

尝试更改web配置以允许此操作,但不起作用。必须找到另一种方法来实现这一点,使用youtube视频中的嵌入url。

尝试更改web配置以允许这样做,但就是不起作用。必须找到另一种方法,使用youtube视频中的嵌入url。

这在我看来是一个错误。这是TypeScript转换为JavaScript的方式,所以它不是关于
函数
关键字的。是的,这看起来不起作用,以后会出现其他错误。很容易使用嵌入URL,出于某种原因,它工作得很好。在我看来,这是一个角度上的错误。这是TypeScript转换为JavaScript的方式,所以它不是关于
函数
关键字的。是的,这看起来不起作用,以后会出现其他错误。很容易使用嵌入URL,出于某种原因,它工作得很好。