I want to take an angular application that works fine on my own domain and 'embed' it into several other sites.
我想采用一个在我自己的域上工作正常的角度应用程序并将其“嵌入”到其他几个站点。
The app uses partials with the ng_view directive so that the only thing i need to do to 'inject' my app into one of my pages is...
该应用程序使用部分与ng_view指令,以便我唯一需要做的是将我的应用程序“注入”我的一个页面是...
<div ng-app="myapp" ng-view></div>
My app looks like this...
我的应用看起来像这样......
angular.module('myapp', ['myapp.filters', 'myapp.services', 'myapp.directives', 'ui']).
config(['$routeProvider', function($routeProvider) {
$routeProvider.otherwise({templateUrl: 'partials/mainTemplate.html', controller: myController});
}]);
this works fine, but when I try to 'inject' the app into another site, In addition to externalizing the script references, I changed the app to look like this...
这工作正常,但当我尝试将应用程序“注入”到另一个站点时,除了将脚本引用外部化之外,我还是将应用程序更改为这样......
angular.module('myapp', ['myapp.filters', 'myapp.services', 'myapp.directives', 'ui']).
config(['$routeProvider', function($routeProvider) {
$routeProvider.otherwise({templateUrl: ''http://mydomain.com/partials/mainTemplate.html', controller: myController});
}]);
But it doesn't work... no errors, no nothing, it just doesn't render my app.
但它不起作用......没有错误,没有任何错误,它只是不呈现我的应用程序。
Any ideas? are external partial references allowed?... is the browser being over-protective? Should I take a completely different approach??
有任何想法吗?允许外部部分引用?...浏览器是否过度保护?我应该采取完全不同的方法吗?
1 个解决方案
#1
1
I think you should enable CORS on mydomain.com in order to get the view. And, as bUKaneer says, you have to add mydomain.com in the $sceDelegateProvider.resourceUrlWhitelist
我认为你应该在mydomain.com上启用CORS才能获得视图。而且,正如bUKaneer所说,你必须在$ sceDelegateProvider.resourceUrlWhitelist中添加mydomain.com
#1
1
I think you should enable CORS on mydomain.com in order to get the view. And, as bUKaneer says, you have to add mydomain.com in the $sceDelegateProvider.resourceUrlWhitelist
我认为你应该在mydomain.com上启用CORS才能获得视图。而且,正如bUKaneer所说,你必须在$ sceDelegateProvider.resourceUrlWhitelist中添加mydomain.com