[英]Having trouble to understand the MEAN.JS scaffolding and how Angular bootstraps
Still learning the basics of MEAN and created a sample project from this article , then decided to use some scaffolding tool to create clean folder structure for my project and i confronted YEOMAN and MEANJS . 仍在学习MEAN的基础知识并从本文创建了一个示例项目,然后决定使用一些脚手架工具为我的项目创建干净的文件夹结构,然后我遇到了YEOMAN和MEANJS 。 Used
npm install -g yo
, npm install -g generator-meanjs
and yo meanjs
, everything worked like a charm n was having a project right infront me. 使用了
npm install -g yo
, npm install -g generator-meanjs
和yo meanjs
,所有工作都像个魅力n在我yo meanjs
有了一个项目。 You can download the entire MEAN project here . 您可以在此处下载整个MEAN项目 。 Few things which i just dont understand despite of analyzing code structure for whole day :
尽管分析了整天的代码结构,但我几乎不了解的几件事:
public
folder and who bootsrapps it ? public
文件夹和谁bootsrapps呢? app/views
folder ? app/views
文件夹中的一些HTML文件有什么用? Especially files like index.server.view.html
and layout.server.view.html
are serving as templates of all other Angular view files / HTML files. index.server.view.html
和layout.server.view.html
这样的文件充当所有其他Angular视图文件/ HTML文件的模板。 How are they even getting hooked up ? application.js
is the AngularJS main application file and who is bringing this into life ? application.js
是AngularJS主应用程序文件,谁将它付诸实践? Am not using anything like Grunt
or Gulp
or Karma
for first cut of the application and may decide to scale it up later, so how do i remove those to get just a MEAN barebone architecture so that its easy to understand n get started. 我不使用
Grunt
或Gulp
或Karma
类的东西作为应用程序的第一版,而是可能决定以后进行扩展,所以我如何删除这些文件以仅得到MEAN准系统架构,以便其易于理解和入门。
Yes, all your front-end stuff is inside public
folder, and your question about the app/views
folder is actually the answer to how your angular is bootstrapped: 是的,你的所有前端的东西在里面
public
文件夹,你对这个问题app/views
文件夹实际上是回答您的角度如何自举:
The app/views
folder contains a single page of html that will be downloaded according to the route you requested to the server, so if you ask your server to render the localhost:3000/
it will give you the layout.html
and probably the index.html
file. app/views
文件夹包含一个html页面,该页面将根据您请求到服务器的路由下载,因此,如果您要求服务器呈现localhost:3000/
,它将为您提供layout.html
以及可能的index.html
文件。 Your layout file may have a ng-app="YourApp"
, and that's what bootstraps the angular, which is probably under your application.js
file with something like angular.module('YourApp')
. 您的布局文件可能具有
ng-app="YourApp"
,这就是引导角度的原因,它可能在您的application.js
文件下并带有angular.module('YourApp')
。 Note that 'YourApp'
MUST be the name of the directive ng-app
in the layout/index file and that's how angular gets set up. 请注意,
'YourApp'
必须是布局/索引文件中指令ng-app
的名称,这就是角度设置的方式。
Okay, knowing that you should note that localhost:3000/home/
would render the layout.html
plus home.html
files, and so on. 好的,知道您应该注意
localhost:3000/home/
会呈现layout.html
和home.html
文件,依此类推。 Therefore, each of these app/views
pages should have several partials
to work as a SPA application to the user, for example: localhost:3000/home#profile
would be the same view page as the localhost:3000/home#dashboard
, what changes is the angular partials. 因此,这些
app/views
页面中的每个页面都应具有多个partials
才能作为用户的SPA应用程序使用,例如: localhost:3000/home#profile
与localhost:3000/home#dashboard
是同一视图页面,变化是角偏角。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.