有没有办法将angularJS应用程序作为聚合物组件运行? [英] Is there a way to run angularJS app as polymer component?

查看:58
本文介绍了有没有办法将angularJS应用程序作为聚合物组件运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种方法,以其自身的样式和视图将异步angularJS应用程序包含到JS中,并将其包含到Polymer组件中.制作某种iframe.

I am looking a way to include asynchronously angularJS application with it's own styles and views included to JS into Polymer component. To make some kind of iframe.

如果您有任何想法,建议或实际示例,那将非常有帮助!

If you have any ideas, suggestions or real-world examples, it would be really helpfull!

推荐答案

最后,我自己找到了一个解决方案.仅需在特定元素上引导角度应用程序,以避免冲突,以防它将运行多个应用程序.并实现了脚本的ajax调用.

Finally, I found a solution on my own. Just needed to bootstrap angular application on the specific element to avoid conflicts in case it will run more than one application. And implemented ajax calling of the script.

示例:

<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元素上启动有角度的应用程序.我们可以单独部署角度应用程序,并将其保存在聚合物容器中.它为我们提供了灵活性,并加快了页面的下载速度.

In this case, angular app bootstrapping on the my-app element. And we can deploy separately angular application, and hold it in the polymer container. It gives us flexibility, and speed download of the page.

这篇关于有没有办法将angularJS应用程序作为聚合物组件运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆