有没有办法让 运行 angularJS app 作为 polymer 组件?
Is there a way to run angularJS app as polymer component?
我正在寻找一种方法来异步包含 angularJS 应用程序,将其自己的样式和视图包含到 JS 到 Polymer 组件中。做某种iframe
。
如果您有任何想法、建议或实际示例,那将非常有帮助!
最后,我自己找到了解决办法。只需要在特定元素上 bootstrap angular 应用程序,以避免在 运行 多个应用程序时发生冲突。并实现了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>
在这种情况下,angular 应用 bootstrapping my-app
元素。我们可以单独部署 angular 应用程序,并将其保存在聚合物容器中。它为我们提供了灵活性和页面下载速度。
我正在寻找一种方法来异步包含 angularJS 应用程序,将其自己的样式和视图包含到 JS 到 Polymer 组件中。做某种iframe
。
如果您有任何想法、建议或实际示例,那将非常有帮助!
最后,我自己找到了解决办法。只需要在特定元素上 bootstrap angular 应用程序,以避免在 运行 多个应用程序时发生冲突。并实现了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>
在这种情况下,angular 应用 bootstrapping my-app
元素。我们可以单独部署 angular 应用程序,并将其保存在聚合物容器中。它为我们提供了灵活性和页面下载速度。