[英]What is the best way in which ionic application code can be split?
I am building an ionic app and as the application is going large, the code is also going messy. 我正在构建一个离子应用程序,随着应用程序变得越来越大,代码也变得混乱。 Right now the structure is like this :
现在结构是这样的:
How can i make my code modularized ? 如何使我的代码模块化? something like this :
这样的事情:
js/
`-controllers/
`- controller_A.js
`-services/
`- service_A.js
app.js
I also used requireJS
but i didn't understand the concept. 我也使用
requireJS
但我不明白这个概念。 Right now i am using gulp to concatinate all the files under js/
directory and bundle it into bundle.js
. 现在我正在使用gulp来整合
js/
目录下的所有文件并将其捆绑到bundle.js
。
Please tell me how to make a best structure on which i can build application 请告诉我如何建立一个可以构建应用程序的最佳结构
I highly encourage you to group your files (html / js) by feature rather than file type. 我强烈建议您按功能而不是文件类型对文件(html / js)进行分组。 This approach will significantly ease development for you.
这种方法将大大简化您的开发。
So your directory should look like this: 所以你的目录应该是这样的:
app/
login/
login.controller.js
login.template.html
login.scss
You may use a task runner (Gulp / Grunt) to compile and copy the files into dest (www) directory. 您可以使用任务运行器(Gulp / Grunt)将文件编译并复制到dest(www)目录中。
Check out angular style guide by John Papa. 查看John Papa的角度风格指南 。 A great resource for angular's best coding practices.
角度最佳编码实践的重要资源。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.