我正在寻找一种方法来包含异步angularJS应用程序,并将自己的样式和视图包含在JS中的Polymer组件中。制作某种iframe
。
如果您有任何想法,建议或现实世界的例子,那将非常有帮助!
答案 0 :(得分:5)
最后,我自己找到了一个解决方案。只需要在特定元素上引导角度应用程序,以避免在运行多个应用程序时发生冲突。并实现了脚本的ajax调用。
示例:
<link rel="import" href="../polymer/polymer.html">
<!-- Defines element markup -->
<dom-module id="my-element">
<template>
<div id="my-app">
<ui-view></ui-view>
</div>
</template>
<!-- Registers custom element -->
<script>
Polymer({
is: 'my-element',
// Fires when an instance of the element is created
created: function() {},
// Fires when the local DOM has been fully prepared
ready: function() {
$.getScript('./app/may-ng-app.min.js');
},
// Fires when the element was inserted into the document
attached: function() {},
// Fires when the element was removed from the document
detached: function() {},
// Fires when an attribute was added, removed, or updated
attributeChanged: function(name, type) {}
});
</script>
</dom-module>
在这种情况下,my-app
元素上的角度app引导。我们可以单独进行角度应用,并将其固定在聚合物容器中。它为我们提供了灵活性和页面下载速度。