0

部署到 Windows 8.1 的 Cordova 版本 4.0 阻止外部模板

        .when('/', {
            controller: 'login',
            templateUrl: 'http://ip-address/templates/login.html',
            resolve: resolver('login')
        })

注意:这不是 InAppBrowser 应用程序。index.html 是本地的,router.js config.xml 也是如此

<access origin="*" />

因此,不应出现任何跨域问题。

4

2 回答 2

1

我不知道这是否会有所帮助,所以我只是发表评论(请参阅有问题的评论)。我的 index.html 文件中有这个,而我需要访问 templates.com 上的模板(例如):

<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval' *.azure-mobile.net http://localhost:1337 http://ajax.aspnetcdn.com">
于 2016-03-15T23:47:16.200 回答
0

潜在问题似乎是跨源问题,但通过以下解决方法解决了这个问题。基本理论是 $http.get 能够解析 text/html 或 application/json。

app.run(....)

            var allTemplates = [
                'my-template-1.html',
                'login-template.html',
                'logout-template.html',
                'unsupportedversion.html'
            ];

            allTemplates.forEach(function(template){
                $http.get('http://example.com/templates/'+template).success(function (t) {
                    $templateCache.put('templates/'+template, t);
                }).error(function(data, status, headers, config) {
                    $rootScope.appErrors.push(template+' failedToLoad');
                });
            });
于 2016-03-17T16:59:18.427 回答