.state('home', {
name: 'home',
url: '/home',
templateUrl: 'http://*********.net/*******/Views/Home.htm',
controller: 'HomeController'
})
.state('history', {
name: 'history',
url: '/history/:frid',
templateUrl: 'http://*********.net/*******/Views/History.htm',
controller: 'HistoryController'
})
我想动态绑定HTML文件.....但我无法用我的angualarjs应用程序执行此操作。
它附加到当前网址,如:
localhost://8000:http://*********.net/*******/Views/History.htm
并且无法加载。
请帮助解决这个问题。
此外,我进入控制台..跨浏览器异常以获取HTML表单远程资源
答案 0 :(得分:0)
有一个名为$sce
(docs)的角度服务,用于配置哪些上下文应被视为有害和副verca。
在文档中有一段关于它如何影响加载模板(here)的段落。简而言之,默认情况下,angular允许仅从与应用程序相同的域和协议加载模板,除非您将某些其他域列入白名单。您可以在$sceDelegateProvider
(docs)的帮助下完成此操作。
angular.module('myApp', []).config(function($sceDelegateProvider) {
$sceDelegateProvider.resourceUrlWhitelist([
// Allow same origin resource loads.
'self',
// Allow loading from your templates domain
'http://some.example.com/**'
]);
此外,您必须在要为其提供模板的服务器上配置CORS。
答案 1 :(得分:0)
得到了解决方案。跨浏览器问题对浏览器的影响,但不在Android设备中。现在我从服务器获取我的Js和Views .....为资源服务器设置cors ...感谢Michael