如何使用 AngularJS/Ionic 作为 Backbone/Cordova 项目的一部分? [英] How to use AngularJS/Ionic as part of Backbone/Cordova project?

查看:24
本文介绍了如何使用 AngularJS/Ionic 作为 Backbone/Cordova 项目的一部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 AngularJS/Ionic 的新手,所以我请求您的帮助给我们一些关于如何将 AngularJS/Ionic 添加到 Backbone 项目的一部分的想法.

我们手头有一个基于 Cordova 中的 Backbone 框架构建的项目.现在我们正在寻找在 AngularJS 中完成我们的部分工作.我们的想法是使用 requireJS 在 Backbone 中创建新页面并实现 AngularJS 显示的内容.

<小时>

例如,我们通过init创建一个新页面并在Backbone中渲染它,在返回的html中,它有Angular的东西,例如:

<p>我的第一个表达式:{{ 5 + 5 }}</p>

我们在 Cordova 上安装 Ionic 并将它们导入到 index.html 中:

 <script src="lib/ionic/js/ionic.bundle.js"></script><script src="js/main.js"></script>

在 Chrome 调试模式下,angular 可以使用了,但是 html 仍然被解析为纯文本

我的第一个表达式:{{ 5 + 5 }}

<小时>

一个想法是导入了 angular 但它在主视图上,我们创建的新页面是通过单击主视图上的按钮创建的另一个视图.Cordova 通过将主视图放在当前视图的顶部来替换主视图,该视图仍然向客户端显示相同"页面.所以在这种情况下,AngularJS 不知道它应该在哪里工作.我试图在 Chrome 调试模式下呈现 html 后触发 angular,它显示 $scope 为未定义.

<小时>

任何来自架构观点、编码方面、演示、任何方面的想法都非常受欢迎.即使您认为基于两种不同的框架是不可能的,请在下面留下您的理由.非常感谢!

解决方案

我自己找到了答案.

是的.它可以将 AngularJS/Ionic 添加到现有的 Backbone/Cordova 项目中.我找到了一个很好的例子,https://gist.github.com/geddski/5571990.

想法还是用Backbone来创建页面,但是在页面内部,是AngularJS在上面实现视图.Ionic 1.0 可以直接安装在 Cordova 项目中.

希望这会有所帮助.如果您有任何问题或任何更新的信息,请随时回复.谢谢.

I am new to AngularJS/Ionic so I am asking for your helps to give us some ideas about how to add AngularJS/Ionic to part of Backbone project.

We have a project on hand which is built based on Backbone framework in Cordova. Now we are looking for doing part of our jobs in AngularJS. What we are thinking is to create new pages in Backbone with requireJS and implement what to show by AngularJS.


For example, we create a new page by init and render it in Backbone and in the html returned, it has Angular stuff such as:

<div >
    <p>My first expression: {{ 5 + 5 }}</p>
</div>

We installs Ionic on top of Cordova and import them in index.html with:

    <link href="lib/ionic/css/ionic.css" rel="stylesheet">
    <script src="lib/ionic/js/ionic.bundle.js"></script>
    <script src="js/main.js"></script>

In the Chrome debug mode, angular is ready to use but the html is still parsed as plain text as

My first expression: {{ 5 + 5 }}


One thought is angular is imported but it is on the main view, the new page we created is another view by clicking a button on main view. Cordova replace the main view by put it on top of current view which is still show the 'same' page to client. So in this case, AngularJS does not know where should it work on. I tried to trigger angular after html is rendered in Chrome debug mode, it shows $scope as undefined.


Any ideas from architecture point of views, from coding side, from demo, from anything are very welcomed. Even if you believe it is impossible based on two different frameworks, please leave your reasons below. Great appreciates!

解决方案

I found the answer by myself.

Yes. It can add AngularJS/Ionic to an existed Backbone/Cordova project. I found a good example for it, https://gist.github.com/geddski/5571990.

The idea is to still using Backbone to create a page, but inside the page, it is AngularJS on top of it to implement views. Ionic 1.0 can install in Cordova project directly.

Hope this could help. If you have any questions or any updated information, please feel free to reply. Thank you.

这篇关于如何使用 AngularJS/Ionic 作为 Backbone/Cordova 项目的一部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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