简体   繁体   English

离子应用程序代码可以拆分的最佳方式是什么?

[英]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.

相关问题 在打字稿中拆分字符串的最佳方法是什么 - What is the best way to split the string in typescript 重构此代码的最佳方法是什么? - What is the best way to refactor this code? 在具有仪表板和登陆的React应用程序中处理CSS样式冲突的最佳方法是什么? - What is the best way to deal with CSS style conflicts in React application which has dashboard and landing? 找出更改页面中特定html内容的javascript代码的最佳方法是什么? - What's the best way to figure out which javascript code that change specific html content in page 链接到Facebook应用程序框架的最佳方法是什么? - What is the best way to link into the frame of Facebook application? 在javascript中执行split()并忽略空白条目的最佳方法是什么? - What is the best way to do split() in javascript and ignore blank entries? 均匀分组的最好方法是什么? - What's the best way to evenly split a groups total? 分割字符串的最佳方法是什么(可能是复杂的正则表达式)? (JavaScript的/ jquery的) - What is the best way to split a string (possible with complicated regex)? (javascript/jquery) 编写此 React 代码的最佳方法是什么? - What is the best way to write this React code? 在angularjs中运行jquery代码的最佳方法是什么? - what is the best way to run jquery code in angularjs?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM