【发布时间】:2014-09-04 00:20:43
【问题描述】:
我在将现有的 django 应用程序与 angular 集成时遇到问题,我已将 Amazon AWS 与 Boto 设置为静态文件,但在使用 AngularJs 时出现此错误:
Blocked loading resource from url not allowed by $sceDelegate policy. URL:
所以我调查并尝试这样做:
$sceDelegateProvider.resourceUrlWhitelist(['self',djangoStaticURL]);
在我的模块配置上,但 dopes 似乎不起作用,所以我尝试了:
templateUrl: $sceProvider.trustAsResourceUrl(djangoStaticURL + 'app/views/main.html'),
并且得到 $sce 提供者未定义,这是我完整的模块:
angular.module('portfolioApp', [
'ngCookies',
'ngResource',
'ngSanitize',
'ngRoute',
'portfolioApp.filters',
]).config(function ($sce ,$routeProvider, $sceDelegateProvider) {
$sceDelegateProvider.resourceUrlWhitelist(['self',djangoStaticURL]);
$routeProvider
.when('/', {
templateUrl: $sce.trustAsResourceUrl(djangoStaticURL + 'app/views/main.html'),
//templateUrl: djangoStaticURL + 'app/views/main.html',
controller: 'MainCtrl'
})
.otherwise({
redirectTo: '/'
});
});
所以这是个坏主意吗?我应该从 django 完成所有路由吗?还是我错过了什么?
【问题讨论】:
-
你有没有想过这个问题?
-
@Brendan 其实是的,看看我的回答
标签: django angularjs amazon-web-services static amazon-s3