<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://classes.engineering.wustl.edu/cse330/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Vigo</id>
	<title>CSE330 Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="http://classes.engineering.wustl.edu/cse330/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Vigo"/>
	<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Special:Contributions/Vigo"/>
	<updated>2026-11-15T21:32:41Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.34.4</generator>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_9&amp;diff=1745</id>
		<title>Module 9</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_9&amp;diff=1745"/>
		<updated>2014-05-15T17:06:32Z</updated>

		<summary type="html">&lt;p&gt;Vigo: /* Tips */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
&lt;br /&gt;
This module introduces MEAN, a fullstack web framework that uses '''M'''ongoDB, '''E'''xpress, '''A'''ngularJS and '''N'''ode.js. &amp;lt;br/&amp;gt;&lt;br /&gt;
You have already learned (some things) about Node.js. In this module, you will be introduced to other three new technologies. Don’t frown yet, the goal of this module is to expose you to the concept of web frameworks and prepare you for the creative project. You are not required to be an expert in all of these technologies, however, it’s important to understand the basics of each and how they work together.&lt;br /&gt;
Follow along the tutorials and complete exercises to learn how things work, and you will be ready to create your own web applications using the MEAN stack very soon!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Reading ==&lt;br /&gt;
&lt;br /&gt;
The following articles on the online class wiki textbook contain information that will help you complete the assignment.&lt;br /&gt;
&lt;br /&gt;
*[[Preparations]]&lt;br /&gt;
*[[Getting MEAN]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignments ==&lt;br /&gt;
&lt;br /&gt;
=== Tutorials ===&lt;br /&gt;
&lt;br /&gt;
Make sure you go through tutorials for both MongoDB and AngularJS, and understand how Express works.&lt;br /&gt;
&lt;br /&gt;
=== Install MEAN ===&lt;br /&gt;
&lt;br /&gt;
Follow the steps and install MEAN on your machine, initialize an app and type grunt in your terminal to start the server (make sure your mongoDB server is connected and running).&lt;br /&gt;
Open up the app in your browser (localhost:3000), and understand what the default app does.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Group Project ==&lt;br /&gt;
* Make an e-commerce site using the MEAN stack.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To start, come up with use cases for your site. Think about what products the site is selling, what the user can do, and how information is stored etc.&lt;br /&gt;
&lt;br /&gt;
You may start with the default MEAN.io app and build on top of it. This way you don't have to implement user authentication. You can also create a MEAN package and start from there. &amp;lt;br/&amp;gt;&lt;br /&gt;
You may use phone models provided by the Angular Phone Catalog app as your products. Review the MongoDB section on how to import JSON data into MongoDB.&lt;br /&gt;
&lt;br /&gt;
==== Tips ====&lt;br /&gt;
&lt;br /&gt;
Review the &amp;quot;Getting MEAN&amp;quot; section to understand the file system so you know how components work with each other.&lt;br /&gt;
Keep in mind that you don't have to understand what every line of code does. Whenever in doubt, refer to the default app.&lt;br /&gt;
&lt;br /&gt;
You will be making changes on both the server side (the /server directory of your app) and the client side (in the /public directory)&lt;br /&gt;
#* Server Side:&lt;br /&gt;
Model: add model files to the /server/models folder. There are Mongoose files that define the objects, they are referenced by the controllers.&lt;br /&gt;
View: nothing to change&lt;br /&gt;
Controller: add controller file(s) for your models (/server/controllers), they are referenced by the routing file&lt;br /&gt;
Routing: add a js file in /server/routes folder that responds to client side requests (same format as the one in the default app) &lt;br /&gt;
#* Client Side&lt;br /&gt;
Model: nothing to change&lt;br /&gt;
View: (/public/views directory) views are .html files. Each view that requires data from the server side should be tied to a controller, inside the controller, you can specify methods to update/save/delete objects in the DB,  the view and routing section gives an example&lt;br /&gt;
Controller: add controller files to /public/controllers. Easy once you go through the AngularJS tutorial. You may need to add multiple services in the /public/services directory (tutorial part 11, and the default MEAN app) to use data received from the back end and persist data across views (look up ngCookie, $cookieStore or the HTML 5 localStorage solution).&lt;br /&gt;
Routing: /public/routes directory of your app. Add entries for all views you will use, and specify their urls and templates (stored in /public/views).&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
We will be grading the following aspects of your work.  There are 100 points total.&lt;br /&gt;
&lt;br /&gt;
# '''Working E-commerce Site (75 points)'''&lt;br /&gt;
#* MEAN installed and set up correctly (10 points).&lt;br /&gt;
#* Models set up correctly (15 points).&lt;br /&gt;
#*: ''including products, orders, and adding payment and shipping address to the user model, you don't have to use phones from the Angular tutorial but you are responsible for populating your products table''&lt;br /&gt;
#* Can display a list of all products, can search, can view details (15 points).&lt;br /&gt;
#* Can add to cart, view cart, cart sustains (data can be accessed across views and shouldn't be lost when page is refreshed) (20 points).&lt;br /&gt;
#* Can check out (5 points).&lt;br /&gt;
#*: ''A user can check out if she has a payment option and a shipping address, on a successful checkout, the cart should be emptied''&lt;br /&gt;
#* Can view orders, delete orders (10 points).&lt;br /&gt;
#*: ''An order is associated to a user and should contain at least four fields: date, total, number of products, shipped to''&lt;br /&gt;
# '''Design and Misc (5 Points):'''&lt;br /&gt;
#* Site is overall user friendly and utilizes Bootstrap (3 points).&lt;br /&gt;
#* App passes JShint with no errors (2 points)&lt;br /&gt;
# '''Creative Portion (20 Points):'''&lt;br /&gt;
#* TBD&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 9]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Vigo</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=1744</id>
		<title>Getting MEAN</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=1744"/>
		<updated>2014-05-15T06:38:40Z</updated>

		<summary type="html">&lt;p&gt;Vigo: /* Controllers */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Installation=&lt;br /&gt;
To install MEAN, make sure you already have all of the following components installed and configured correctly.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
'''1. Node.js''' (should come with npm) &amp;lt;br/&amp;gt;&lt;br /&gt;
To find out if you have node and npm, try checking their versions (may not be the same):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
node --version&lt;br /&gt;
v0.10.25&lt;br /&gt;
npm --version&lt;br /&gt;
1.3.24&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
IF you don't have node.js, install it [http://nodejs.org/ here].&lt;br /&gt;
&lt;br /&gt;
'''2. Bower'''&lt;br /&gt;
&lt;br /&gt;
Bower is a web application manager used by MEAN. To install bower, type the following command in your terminal: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;npm i -g bower&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''3. MongoDB'''&lt;br /&gt;
To install MongoDB, follow the instructions for your OS [http://docs.mongodb.org/manual/installation/ here].&lt;br /&gt;
&lt;br /&gt;
'''4. and finally, MEAN'''&lt;br /&gt;
In your terminal, type:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt; &amp;gt; sudo npm install -g meanio@latest &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* MEAN stack documentations are available [http://mean.io/#!/docs here]. They'll help you to get familiar with the file structure and idioms.&lt;br /&gt;
&lt;br /&gt;
=Running the Default App =&lt;br /&gt;
* Init and run an app. &lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; mean init myApp // create your first app&lt;br /&gt;
&amp;gt; cd myApp &lt;br /&gt;
&amp;gt; npm install // Install dependencies&lt;br /&gt;
&amp;gt; grunt // Launch mean&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Make sure MongoDB is connected and running (if you run into problems, refer to the section on MongoDB)&lt;br /&gt;
&lt;br /&gt;
* Go ahead and explore features of the default Article app (such as logging in, adding/deleting articles).&lt;br /&gt;
&lt;br /&gt;
=Generating a Package =&lt;br /&gt;
* By now you should know what a package is in MEAN. If you don't, read [http://mean.io/#!/docs this].&lt;br /&gt;
* Try creating a package named myPackage by typing: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; mean package myPackage;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Locate it inside the packages folder:&lt;br /&gt;
* Compare the structure of myPackage folder to that of the default app. Make sure you see both '''public''' and  '''server''' folders and their subfolders.&lt;br /&gt;
* Restart your app, make sure you can see a link to the newly created package.&lt;br /&gt;
&lt;br /&gt;
=A Closer Look at the App =&lt;br /&gt;
Take a look at the directory where you app resides, you will see two folders '''public''' and  '''server''', which contain code for the client side and server side respectively.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Models ==&lt;br /&gt;
&lt;br /&gt;
Open up article.js in /server/models&lt;br /&gt;
&lt;br /&gt;
MEAN is MVC on the client side and the server side.  Since the model is tied to the backend to MongoDB, you will only see the models folder on the server side, which is normal. &lt;br /&gt;
The models are mongoose models that's why we need to require mongoose (what the following line does):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
var mongoose = require('mongoose'), Schema = mongoose.Schema;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The following part then defines the schema:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
var ArticleSchema = new Schema({&lt;br /&gt;
    created: {&lt;br /&gt;
        type: Date,&lt;br /&gt;
        default: Date.now&lt;br /&gt;
    },&lt;br /&gt;
    title: {&lt;br /&gt;
        type: String,&lt;br /&gt;
        default: '',&lt;br /&gt;
        trim: true&lt;br /&gt;
    },&lt;br /&gt;
    content: {&lt;br /&gt;
        type: String,&lt;br /&gt;
        default: '',&lt;br /&gt;
        trim: true&lt;br /&gt;
    },&lt;br /&gt;
    user: {&lt;br /&gt;
        type: Schema.ObjectId,&lt;br /&gt;
        ref: 'User'&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The next part is validations, or criteria an object needs to pass before it can be saved to the DB. &lt;br /&gt;
The following code is to make sure that an article has a title:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
ArticleSchema.path('title').validate(function(title) {&lt;br /&gt;
    return title.length;&lt;br /&gt;
}, 'Title cannot be blank');&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, Mongoose allows us to define methods to our data objects as well. &lt;br /&gt;
These are called statics. From the Mongoose doc: Schemas not only define the structure of your document and casting of properties, they also define document instance methods, static Model methods, compound indexes and document lifecycle hooks called middleware.&lt;br /&gt;
The following code defines a method called load for the article schema:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
ArticleSchema.statics.load = function(id, cb) {&lt;br /&gt;
    this.findOne({&lt;br /&gt;
        _id: id&lt;br /&gt;
    }).populate('user', 'name username').exec(cb);&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have trouble understanding what the code does, review the Mongoose [http://mongoosejs.com/docs/index.html quick start] guide.&lt;br /&gt;
&lt;br /&gt;
=== Models Practice === &lt;br /&gt;
Define a schema for a model named '''Phone''', name it phone.js and save it in the corresponding folder in 'myPackage' (hint: /packages/myPackage/server/models/)&lt;br /&gt;
A product needs to have the following fields with specific types. Here is an example of a Phone object can be stored in the MongoDB:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;age&amp;quot;: 0, &lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;motorola-xoom-with-wi-fi&amp;quot;, &lt;br /&gt;
        &amp;quot;imageUrl&amp;quot;: &amp;quot;img/phones/motorola-xoom-with-wi-fi.0.jpg&amp;quot;, &lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;Motorola XOOM\u2122 with Wi-Fi&amp;quot;, &lt;br /&gt;
        &amp;quot;snippet&amp;quot;: &amp;quot;The Next, Next Generation\r\n\r\nExperience the future with Motorola XOOM wi.. d by Android 3.0 (Honeycomb).&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is taken from phones.json used by the AngularJS tutorial. If you have gone through the tutorial, you should have realized that instead of using a DB, json files were used to simplify the tutorial.&lt;br /&gt;
Find phones.json in /app/phones in the angular tutorial folder and try importing its content to MongoDB so you can use them in your current MEAN package.&lt;br /&gt;
&amp;lt;br/&amp;gt; Here is how (assuming mongod is running):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; mongo --shell // connect to mongo shell &lt;br /&gt;
&amp;gt; use mean-dev // switches to database used by mean.&lt;br /&gt;
&amp;gt; mongoimport --db mean-dev --collection phones --type json --file ''&amp;lt;path to phones.json&amp;gt;'' --jsonArray // imports json file to the DB&lt;br /&gt;
&amp;gt; show collections // check to see if phones are added to your database&lt;br /&gt;
&amp;gt; coll = db.phones // to see the content of the file&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Controllers ==&lt;br /&gt;
&lt;br /&gt;
You'll find a controllers folder on both the server side and the client (public) side.  &lt;br /&gt;
* The client side controllers are part of the Angular MVC scheme that contains client side logic and may issue requests to the server.&lt;br /&gt;
* The server side controllers deal with the models and requests from the client side.&lt;br /&gt;
&lt;br /&gt;
'''Server side:'''&lt;br /&gt;
&lt;br /&gt;
* Find articles.js in the controllers folder. Try to understand what each part does. &lt;br /&gt;
&lt;br /&gt;
'''Client side:''' open up articles.js in /articles/public/controllers&lt;br /&gt;
Compare the functions defined in ArticlesController, can you find the server side implementation of corresponding functions? &lt;br /&gt;
&lt;br /&gt;
Here is a diagram to help you understand how this works:&lt;br /&gt;
&lt;br /&gt;
[[File:Mean.png]]&lt;br /&gt;
&lt;br /&gt;
== Views &amp;amp; Routing ==&lt;br /&gt;
Even though typically views are implemented and used for the client end, routing happens on both ends.&lt;br /&gt;
&lt;br /&gt;
* Find articles.js in /server/routes&lt;br /&gt;
You'll see that it requires the articles controller and its methods for querying the database.&lt;br /&gt;
&lt;br /&gt;
The first section requires the articles controller, which defines different methods &lt;br /&gt;
&lt;br /&gt;
For example, code below tells the server to use a method named &amp;quot;all&amp;quot; in the articles controller when the url is pointed to /articles:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;   &lt;br /&gt;
app.route('/articles')&lt;br /&gt;
      .get(articles.all)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Go to http://localhost:3000/articles, what do you see? Does it make sense?&lt;br /&gt;
&lt;br /&gt;
Let's switch to the public folder where the views reside.  Go to articles/public/views, open up list.html: &amp;lt;br/&amp;gt;&lt;br /&gt;
The first line tells the framework that  ArticlesController is responsible for this particular view and when this view is loaded, use find() to initiate data binding.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;section data-ng-controller=&amp;quot;ArticlesController&amp;quot; data-ng-init=&amp;quot;find()&amp;quot;&amp;gt; &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Feel free to take a look at what find() does. Make sure you understand that what find() does is actually done by the backend, where a corresponding find() is written (as mentioned above).&lt;br /&gt;
Hopefully you have a better understanding of how these technologies all work together now.&lt;br /&gt;
&lt;br /&gt;
Review the AngularJS section if you have any questions regarding the view data binding.&lt;br /&gt;
&lt;br /&gt;
The view files in articles/views only defines the code for displaying the articles, where does the navigation bar gets defined.&lt;br /&gt;
The answer is in /public/system. &lt;br /&gt;
*The .html files in public/system/views provide a container/layout for the application. &lt;br /&gt;
For example, header.html includes the menu bar (displayed on the top of the page):&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;left pull-left&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;ul class=&amp;quot;navbar-nav nav&amp;quot;&amp;gt;&lt;br /&gt;
         &amp;lt;li data-ng-repeat=&amp;quot;item in menus.main&amp;quot; ui-route=&amp;quot;/{{item.link}}&amp;quot; ng-class=&amp;quot;{active: $uiRoute}&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;a mean-token=&amp;quot;item.link&amp;quot; ui-sref='{{item.link}}'&amp;gt;{{item.title}}&amp;lt;/a&amp;gt;&lt;br /&gt;
        &amp;lt;/li&amp;gt;&lt;br /&gt;
   &amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Try changing &amp;lt;nowiki&amp;gt;{{item.title}} &amp;lt;/nowiki&amp;gt; inside the &amp;lt;a&amp;gt; &amp;lt;/a&amp;gt;tags to &amp;quot;my articles&amp;quot; see what happens to the page.&lt;br /&gt;
* The ui-sref is &amp;quot;href&amp;quot; in ui-route, an AngularJS plugin, try changing &amp;lt;nowiki&amp;gt;{{item.link}}&amp;lt;/nowiki&amp;gt; to #!/myarticles, &lt;br /&gt;
* What happens to the application now? When you click on &amp;quot;my articles&amp;quot;?&lt;br /&gt;
&lt;br /&gt;
The page to articles is no longer served!&lt;br /&gt;
&lt;br /&gt;
But how does the framework know which page to serve given a certain url?  The file responsible for this (called routing in web development) is in public/articles/routes&lt;br /&gt;
&lt;br /&gt;
open up articles.js in this folder and find the line that specifies the routing scheme for /articles:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
            .state('all articles', {&lt;br /&gt;
                url: '/articles',&lt;br /&gt;
                templateUrl: 'public/articles/views/list.html',&lt;br /&gt;
                resolve: {&lt;br /&gt;
                    loggedin: checkLoggedin&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is ui-route's way of telling the server what to serve the page specified by the templateUrl when it sees &amp;quot;localhost:3000/#!/phones&amp;quot;. &lt;br /&gt;
The #! is a hash prefix used for MEAN to make ajax calls so make sure to include it when coding your views.&lt;br /&gt;
Now try changing the url to &amp;quot;/myarticles&amp;quot;, save and go back to your app, click on &amp;quot;my articles&amp;quot; now, what happens?&lt;br /&gt;
&lt;br /&gt;
*This is important if you want to customize your navigation bar and links. Just remember that each url needs an entry in the route file, in the format of the example above.&lt;br /&gt;
&lt;br /&gt;
= Practice = &lt;br /&gt;
&lt;br /&gt;
Can you implement a view in your myPackage to display all phones injected in the DB? &lt;br /&gt;
Hint: myPackage has the same file structure as the default app.&lt;/div&gt;</summary>
		<author><name>Vigo</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=File:Mean.png&amp;diff=1743</id>
		<title>File:Mean.png</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=File:Mean.png&amp;diff=1743"/>
		<updated>2014-05-15T06:24:59Z</updated>

		<summary type="html">&lt;p&gt;Vigo: diagram explains the mean stack&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;diagram explains the mean stack&lt;/div&gt;</summary>
		<author><name>Vigo</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Preparations&amp;diff=1742</id>
		<title>Preparations</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Preparations&amp;diff=1742"/>
		<updated>2014-05-15T06:13:36Z</updated>

		<summary type="html">&lt;p&gt;Vigo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Full Stack==&lt;br /&gt;
In web development, full stack refers to all the layers involved in building a working web application, including data modeling, server, network, user interface, business logic etc. &lt;br /&gt;
In this module we will focus on the technical layers that are essential for a successful web product, which translates to front end and back end skills. &lt;br /&gt;
&lt;br /&gt;
MEAN is a collection of javascript frameworks and its components are:&lt;br /&gt;
Front end: AngularJS (client side MVC) , Bootstrap*&lt;br /&gt;
Back end: Express(server side MVC), with Node.js API &lt;br /&gt;
Data Base: MongoDB&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Why MEAN? ==&lt;br /&gt;
Can I use a SQL database instead of MongoDB? Or a different front end framework like instead of Angular? Sure, but these technologies work beautifully together as they all use the same language – Javascript. For the first time ever we can create web software applications entirely using one language and this gives developers tremendous power. &lt;br /&gt;
The diagram below explains how things work:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== MongoDB ===&lt;br /&gt;
MongoDB is a leading NoSQL database that uses JSON-style documents with dynamic schemas. It uses Javascript as a language to modify and query the database and JSON format to store the data&lt;br /&gt;
'''Go through this very short tutorial for MongoDB''' [http://try.mongodb.org here]. This 5 minute tutorial will help you understand how MongoDB works as a noSQL DB service.&lt;br /&gt;
Even though MongoDB is fast, scalable and easy to use, to make it work with the MEAN stack, we need an object modeling service called Mongoose. &amp;lt;br/&amp;gt;&lt;br /&gt;
'''Skim through the Mongoose guide (getting started)''' [http://mongoosejs.com/docs/index.html here] to understand how it works. &lt;br /&gt;
&lt;br /&gt;
=== Express===&lt;br /&gt;
Express is a minimal and flexible node.js web application framework, and has become the dominant server-side MVC framework for Node.js. Express defines the responses to each type of HTTP request at each defined route and treats the request and responses as objects you can manipulate in any way you see fitting.&lt;br /&gt;
You will not be coding anything for Express in this module (already done by MEAN.io). Take a look at it [http://expressjs.com/guide.html here]&lt;br /&gt;
&lt;br /&gt;
=== AngularJS===&lt;br /&gt;
AngularJS is a client-side MVC javascript framework by Google and it aims to increase developer productivity and creativity by providing a complete solution for large-scale applications and many powerful out of the box features.&lt;br /&gt;
AngularJS is important to this module. Please go through the tutorial [https://docs.angularjs.org/tutorial here].&lt;br /&gt;
&lt;br /&gt;
===Node.js===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Bootstrap===&lt;br /&gt;
Bootstrap is the default front end framework for the MEAN.io project. Though you could switch to other frameworks such as Foundation pretty easily.&lt;/div&gt;</summary>
		<author><name>Vigo</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Preparations&amp;diff=1741</id>
		<title>Preparations</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Preparations&amp;diff=1741"/>
		<updated>2014-05-15T05:57:07Z</updated>

		<summary type="html">&lt;p&gt;Vigo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Full Stack==&lt;br /&gt;
In web development, full stack refers to all the layers involved in building a working web application, including data modeling, server, network, user interface, business logic etc. &lt;br /&gt;
In this module we will focus on the technical layers that are essential for a successful web product, which translates to front end and back end skills. &lt;br /&gt;
&lt;br /&gt;
= Why MEAN? =&lt;br /&gt;
&lt;br /&gt;
MEAN is a javascript framework based on a collection of javascript frameworks. It may sound complicated but the way it works is really simple.&lt;br /&gt;
&lt;br /&gt;
The MEAN.io project you'll use as a starting point for the group assignment the developers to focus on creating awesome apps.&lt;br /&gt;
&lt;br /&gt;
Front end: AngularJS, Bootstrap*&lt;br /&gt;
Back end: Node.js (powered Express)&lt;br /&gt;
Data Base: MongoDB&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== MongoDB ===&lt;br /&gt;
MongoDB is a leading NoSQL database that uses JSON-style documents with dynamic schemas. It uses Javascript as a language to modify and query the database and JSON format to store the data&lt;br /&gt;
'''Go through this very short tutorial for MongoDB''' [http://try.mongodb.org here]. This 5 minute tutorial will help you understand how MongoDB works as a noSQL DB service.&lt;br /&gt;
Even though MongoDB is fast, scalable and easy to use, to make it work with the MEAN stack, we need an object modeling service called Mongoose. &amp;lt;br/&amp;gt;&lt;br /&gt;
'''Skim through the Mongoose guide (getting started)''' [http://mongoosejs.com/docs/index.html here] to get a sense of how it works. &lt;br /&gt;
&lt;br /&gt;
=== Express===&lt;br /&gt;
Express is a minimal and flexible node.js web application framework, and has become the dominant server-side MVC framework for Node.js. Express defines the responses to each type of HTTP request at each defined route and treats the request and responses as objects you can manipulate in any way you see fitting.&lt;br /&gt;
You will not be coding anything for Express in this module (already done by MEAN.io). Take a look at it [http://expressjs.com/guide.html here]&lt;br /&gt;
&lt;br /&gt;
=== AngularJS===&lt;br /&gt;
AngularJS is a client-side MVC javascript framework by Google and it aims to increase developer productivity and creativity by providing a complete solution for large-scale applications and many powerful out of the box features.&lt;br /&gt;
AngularJS is important to this module. Please go through the tutorial [https://docs.angularjs.org/tutorial here].&lt;br /&gt;
&lt;br /&gt;
===Node.js===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Bootstrap===&lt;br /&gt;
Bootstrap is the default front end framework for the MEAN.io project. Though you could switch to other frameworks such as Foundation pretty easily.&lt;/div&gt;</summary>
		<author><name>Vigo</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Preparations&amp;diff=1740</id>
		<title>Preparations</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Preparations&amp;diff=1740"/>
		<updated>2014-05-15T05:50:40Z</updated>

		<summary type="html">&lt;p&gt;Vigo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Full Stack === &lt;br /&gt;
In web development, full stack refers to all the layers involved in building a working web application, including data modeling, server, network, user interface, business logic etc. &lt;br /&gt;
In this module we will focus on the technical layers that are essential for a successful web product, which translates to front end and back end skills. &lt;br /&gt;
&lt;br /&gt;
=== Why MEAN? ===&lt;br /&gt;
&lt;br /&gt;
MEAN is a javascript framework based on a collection of javascript frameworks. It may sound complicated but the way it works is really simple.&lt;br /&gt;
&lt;br /&gt;
The MEAN.io project you'll use as a starting point for the group assignment the developers to focus on creating awesome apps.&lt;br /&gt;
&lt;br /&gt;
Front end: AngularJS, Bootstrap*&lt;br /&gt;
Back end: Node.js (powered Express)&lt;br /&gt;
Data Base: MongoDB&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== MongoDB ==&lt;br /&gt;
MongoDB is a leading NoSQL database that uses JSON-style documents with dynamic schemas. It uses Javascript as a language to modify and query the database and JSON format to store the data&lt;br /&gt;
'''Go through this very short tutorial for MongoDB''' [http://try.mongodb.org here]. This 5 minute tutorial will help you understand how MongoDB works as a noSQL DB service.&lt;br /&gt;
Even though MongoDB is fast, scalable and easy to use, to make it work with the MEAN stack, we need an object modeling service called Mongoose. &amp;lt;br/&amp;gt;&lt;br /&gt;
'''Skim through the Mongoose guide (getting started)''' [http://mongoosejs.com/docs/index.html here] to get a sense of how it works. &lt;br /&gt;
&lt;br /&gt;
==Express==&lt;br /&gt;
Express is a minimal and flexible node.js web application framework, and has become the dominant server-side MVC framework for Node.js. Express defines the responses to each type of HTTP request at each defined route and treats the request and responses as objects you can manipulate in any way you see fitting.&lt;br /&gt;
You will not be coding anything for Express in this module (already done by MEAN.io). Take a look at it [http://expressjs.com/guide.html here]&lt;br /&gt;
&lt;br /&gt;
==AngularJS==&lt;br /&gt;
AngularJS is a client-side MVC javascript framework by Google and it aims to increase developer productivity and creativity by providing a complete solution for large-scale applications and many powerful out of the box features.&lt;br /&gt;
&lt;br /&gt;
Very important to this module. Go through the tutorial [https://docs.angularjs.org/tutorial here].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Bootstrap==&lt;br /&gt;
&lt;br /&gt;
Bootstrap is the default front end framework for the MEAN.io project. Though you could switch to other frameworks such as Foundation pretty easily.&lt;/div&gt;</summary>
		<author><name>Vigo</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=1739</id>
		<title>Getting MEAN</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=1739"/>
		<updated>2014-05-12T01:06:09Z</updated>

		<summary type="html">&lt;p&gt;Vigo: /* Views &amp;amp; Routing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Installation=&lt;br /&gt;
To install MEAN, make sure you already have all of the following components installed and configured correctly.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
'''1. Node.js''' (should come with npm) &amp;lt;br/&amp;gt;&lt;br /&gt;
To find out if you have node and npm, try checking their versions (may not be the same):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
node --version&lt;br /&gt;
v0.10.25&lt;br /&gt;
npm --version&lt;br /&gt;
1.3.24&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
IF you don't have node.js, install it [http://nodejs.org/ here].&lt;br /&gt;
&lt;br /&gt;
'''2. Bower'''&lt;br /&gt;
&lt;br /&gt;
Bower is a web application manager used by MEAN. To install bower, type the following command in your terminal: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;npm i -g bower&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''3. MongoDB'''&lt;br /&gt;
To install MongoDB, follow the instructions for your OS [http://docs.mongodb.org/manual/installation/ here].&lt;br /&gt;
&lt;br /&gt;
'''4. and finally, MEAN'''&lt;br /&gt;
In your terminal, type:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt; &amp;gt; sudo npm install -g meanio@latest &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* MEAN stack documentations are available [http://mean.io/#!/docs here]. They'll help you to get familiar with the file structure and idioms.&lt;br /&gt;
&lt;br /&gt;
=Running the Default App =&lt;br /&gt;
* Init and run an app. &lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; mean init myApp // create your first app&lt;br /&gt;
&amp;gt; cd myApp &lt;br /&gt;
&amp;gt; npm install // Install dependencies&lt;br /&gt;
&amp;gt; grunt // Launch mean&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Make sure MongoDB is connected and running (if you run into problems, refer to the section on MongoDB)&lt;br /&gt;
&lt;br /&gt;
* Go ahead and explore features of the default Article app (such as logging in, adding/deleting articles).&lt;br /&gt;
&lt;br /&gt;
=Generating a Package =&lt;br /&gt;
* By now you should know what a package is in MEAN. If you don't, read [http://mean.io/#!/docs this].&lt;br /&gt;
* Try creating a package named myPackage by typing: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; mean package myPackage;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Locate it inside the packages folder:&lt;br /&gt;
* Compare the structure of myPackage folder to that of the default app. Make sure you see both '''public''' and  '''server''' folders and their subfolders.&lt;br /&gt;
* Restart your app, make sure you can see a link to the newly created package.&lt;br /&gt;
&lt;br /&gt;
=A Closer Look at the App =&lt;br /&gt;
Take a look at the directory where you app resides, you will see two folders '''public''' and  '''server''', which contain code for the client side and server side respectively.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Models ==&lt;br /&gt;
&lt;br /&gt;
Open up article.js in /server/models&lt;br /&gt;
&lt;br /&gt;
MEAN is MVC on the client side and the server side.  Since the model is tied to the backend to MongoDB, you will only see the models folder on the server side, which is normal. &lt;br /&gt;
The models are mongoose models that's why we need to require mongoose (what the following line does):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
var mongoose = require('mongoose'), Schema = mongoose.Schema;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The following part then defines the schema:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
var ArticleSchema = new Schema({&lt;br /&gt;
    created: {&lt;br /&gt;
        type: Date,&lt;br /&gt;
        default: Date.now&lt;br /&gt;
    },&lt;br /&gt;
    title: {&lt;br /&gt;
        type: String,&lt;br /&gt;
        default: '',&lt;br /&gt;
        trim: true&lt;br /&gt;
    },&lt;br /&gt;
    content: {&lt;br /&gt;
        type: String,&lt;br /&gt;
        default: '',&lt;br /&gt;
        trim: true&lt;br /&gt;
    },&lt;br /&gt;
    user: {&lt;br /&gt;
        type: Schema.ObjectId,&lt;br /&gt;
        ref: 'User'&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The next part is validations, or criteria an object needs to pass before it can be saved to the DB. &lt;br /&gt;
The following code is to make sure that an article has a title:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
ArticleSchema.path('title').validate(function(title) {&lt;br /&gt;
    return title.length;&lt;br /&gt;
}, 'Title cannot be blank');&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, Mongoose allows us to define methods to our data objects as well. &lt;br /&gt;
These are called statics. From the Mongoose doc: Schemas not only define the structure of your document and casting of properties, they also define document instance methods, static Model methods, compound indexes and document lifecycle hooks called middleware.&lt;br /&gt;
The following code defines a method called load for the article schema:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
ArticleSchema.statics.load = function(id, cb) {&lt;br /&gt;
    this.findOne({&lt;br /&gt;
        _id: id&lt;br /&gt;
    }).populate('user', 'name username').exec(cb);&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have trouble understanding what the code does, review the Mongoose [http://mongoosejs.com/docs/index.html quick start] guide.&lt;br /&gt;
&lt;br /&gt;
=== Models Practice === &lt;br /&gt;
Define a schema for a model named '''Phone''', name it phone.js and save it in the corresponding folder in 'myPackage' (hint: /packages/myPackage/server/models/)&lt;br /&gt;
A product needs to have the following fields with specific types. Here is an example of a Phone object can be stored in the MongoDB:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;age&amp;quot;: 0, &lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;motorola-xoom-with-wi-fi&amp;quot;, &lt;br /&gt;
        &amp;quot;imageUrl&amp;quot;: &amp;quot;img/phones/motorola-xoom-with-wi-fi.0.jpg&amp;quot;, &lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;Motorola XOOM\u2122 with Wi-Fi&amp;quot;, &lt;br /&gt;
        &amp;quot;snippet&amp;quot;: &amp;quot;The Next, Next Generation\r\n\r\nExperience the future with Motorola XOOM wi.. d by Android 3.0 (Honeycomb).&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is taken from phones.json used by the AngularJS tutorial. If you have gone through the tutorial, you should have realized that instead of using a DB, json files were used to simplify the tutorial.&lt;br /&gt;
Find phones.json in /app/phones in the angular tutorial folder and try importing its content to MongoDB so you can use them in your current MEAN package.&lt;br /&gt;
&amp;lt;br/&amp;gt; Here is how (assuming mongod is running):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; mongo --shell // connect to mongo shell &lt;br /&gt;
&amp;gt; use mean-dev // switches to database used by mean.&lt;br /&gt;
&amp;gt; mongoimport --db mean-dev --collection phones --type json --file ''&amp;lt;path to phones.json&amp;gt;'' --jsonArray // imports json file to the DB&lt;br /&gt;
&amp;gt; show collections // check to see if phones are added to your database&lt;br /&gt;
&amp;gt; coll = db.phones // to see the content of the file&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Controllers ==&lt;br /&gt;
&lt;br /&gt;
You'll find a controllers folder on both the server side and the client (public) side.  &lt;br /&gt;
* The client side controllers are part of the Angular MVC scheme that contains client side logic and may issue requests to the server.&lt;br /&gt;
* The server side controllers deal with the models and requests from the client side.&lt;br /&gt;
&lt;br /&gt;
'''Server side:'''&lt;br /&gt;
&lt;br /&gt;
* Find articles.js in the controllers folder. Try to understand what each part does. &lt;br /&gt;
&lt;br /&gt;
'''Client side:''' open up articles.js in /articles/public/controllers&lt;br /&gt;
Compare the functions defined in ArticlesController, can you find the server side implementation of corresponding functions? &lt;br /&gt;
&lt;br /&gt;
Here is a diagram to help you under stand how this works:&lt;br /&gt;
&lt;br /&gt;
[[File:pic]]&lt;br /&gt;
&lt;br /&gt;
== Views &amp;amp; Routing ==&lt;br /&gt;
Even though typically views are implemented and used for the client end, routing happens on both ends.&lt;br /&gt;
&lt;br /&gt;
* Find articles.js in /server/routes&lt;br /&gt;
You'll see that it requires the articles controller and its methods for querying the database.&lt;br /&gt;
&lt;br /&gt;
The first section requires the articles controller, which defines different methods &lt;br /&gt;
&lt;br /&gt;
For example, code below tells the server to use a method named &amp;quot;all&amp;quot; in the articles controller when the url is pointed to /articles:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;   &lt;br /&gt;
app.route('/articles')&lt;br /&gt;
      .get(articles.all)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Go to http://localhost:3000/articles, what do you see? Does it make sense?&lt;br /&gt;
&lt;br /&gt;
Let's switch to the public folder where the views reside.  Go to articles/public/views, open up list.html: &amp;lt;br/&amp;gt;&lt;br /&gt;
The first line tells the framework that  ArticlesController is responsible for this particular view and when this view is loaded, use find() to initiate data binding.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;section data-ng-controller=&amp;quot;ArticlesController&amp;quot; data-ng-init=&amp;quot;find()&amp;quot;&amp;gt; &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Feel free to take a look at what find() does. Make sure you understand that what find() does is actually done by the backend, where a corresponding find() is written (as mentioned above).&lt;br /&gt;
Hopefully you have a better understanding of how these technologies all work together now.&lt;br /&gt;
&lt;br /&gt;
Review the AngularJS section if you have any questions regarding the view data binding.&lt;br /&gt;
&lt;br /&gt;
The view files in articles/views only defines the code for displaying the articles, where does the navigation bar gets defined.&lt;br /&gt;
The answer is in /public/system. &lt;br /&gt;
*The .html files in public/system/views provide a container/layout for the application. &lt;br /&gt;
For example, header.html includes the menu bar (displayed on the top of the page):&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;left pull-left&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;ul class=&amp;quot;navbar-nav nav&amp;quot;&amp;gt;&lt;br /&gt;
         &amp;lt;li data-ng-repeat=&amp;quot;item in menus.main&amp;quot; ui-route=&amp;quot;/{{item.link}}&amp;quot; ng-class=&amp;quot;{active: $uiRoute}&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;a mean-token=&amp;quot;item.link&amp;quot; ui-sref='{{item.link}}'&amp;gt;{{item.title}}&amp;lt;/a&amp;gt;&lt;br /&gt;
        &amp;lt;/li&amp;gt;&lt;br /&gt;
   &amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Try changing &amp;lt;nowiki&amp;gt;{{item.title}} &amp;lt;/nowiki&amp;gt; inside the &amp;lt;a&amp;gt; &amp;lt;/a&amp;gt;tags to &amp;quot;my articles&amp;quot; see what happens to the page.&lt;br /&gt;
* The ui-sref is &amp;quot;href&amp;quot; in ui-route, an AngularJS plugin, try changing &amp;lt;nowiki&amp;gt;{{item.link}}&amp;lt;/nowiki&amp;gt; to #!/myarticles, &lt;br /&gt;
* What happens to the application now? When you click on &amp;quot;my articles&amp;quot;?&lt;br /&gt;
&lt;br /&gt;
The page to articles is no longer served!&lt;br /&gt;
&lt;br /&gt;
But how does the framework know which page to serve given a certain url?  The file responsible for this (called routing in web development) is in public/articles/routes&lt;br /&gt;
&lt;br /&gt;
open up articles.js in this folder and find the line that specifies the routing scheme for /articles:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
            .state('all articles', {&lt;br /&gt;
                url: '/articles',&lt;br /&gt;
                templateUrl: 'public/articles/views/list.html',&lt;br /&gt;
                resolve: {&lt;br /&gt;
                    loggedin: checkLoggedin&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is ui-route's way of telling the server what to serve the page specified by the templateUrl when it sees &amp;quot;localhost:3000/#!/phones&amp;quot;. &lt;br /&gt;
The #! is a hash prefix used for MEAN to make ajax calls so make sure to include it when coding your views.&lt;br /&gt;
Now try changing the url to &amp;quot;/myarticles&amp;quot;, save and go back to your app, click on &amp;quot;my articles&amp;quot; now, what happens?&lt;br /&gt;
&lt;br /&gt;
*This is important if you want to customize your navigation bar and links. Just remember that each url needs an entry in the route file, in the format of the example above.&lt;br /&gt;
&lt;br /&gt;
= Practice = &lt;br /&gt;
&lt;br /&gt;
Can you implement a view in your myPackage to display all phones injected in the DB? &lt;br /&gt;
Hint: myPackage has the same file structure as the default app.&lt;/div&gt;</summary>
		<author><name>Vigo</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=1738</id>
		<title>Getting MEAN</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=1738"/>
		<updated>2014-05-12T01:04:57Z</updated>

		<summary type="html">&lt;p&gt;Vigo: /* Views &amp;amp; Routing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Installation=&lt;br /&gt;
To install MEAN, make sure you already have all of the following components installed and configured correctly.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
'''1. Node.js''' (should come with npm) &amp;lt;br/&amp;gt;&lt;br /&gt;
To find out if you have node and npm, try checking their versions (may not be the same):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
node --version&lt;br /&gt;
v0.10.25&lt;br /&gt;
npm --version&lt;br /&gt;
1.3.24&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
IF you don't have node.js, install it [http://nodejs.org/ here].&lt;br /&gt;
&lt;br /&gt;
'''2. Bower'''&lt;br /&gt;
&lt;br /&gt;
Bower is a web application manager used by MEAN. To install bower, type the following command in your terminal: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;npm i -g bower&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''3. MongoDB'''&lt;br /&gt;
To install MongoDB, follow the instructions for your OS [http://docs.mongodb.org/manual/installation/ here].&lt;br /&gt;
&lt;br /&gt;
'''4. and finally, MEAN'''&lt;br /&gt;
In your terminal, type:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt; &amp;gt; sudo npm install -g meanio@latest &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* MEAN stack documentations are available [http://mean.io/#!/docs here]. They'll help you to get familiar with the file structure and idioms.&lt;br /&gt;
&lt;br /&gt;
=Running the Default App =&lt;br /&gt;
* Init and run an app. &lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; mean init myApp // create your first app&lt;br /&gt;
&amp;gt; cd myApp &lt;br /&gt;
&amp;gt; npm install // Install dependencies&lt;br /&gt;
&amp;gt; grunt // Launch mean&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Make sure MongoDB is connected and running (if you run into problems, refer to the section on MongoDB)&lt;br /&gt;
&lt;br /&gt;
* Go ahead and explore features of the default Article app (such as logging in, adding/deleting articles).&lt;br /&gt;
&lt;br /&gt;
=Generating a Package =&lt;br /&gt;
* By now you should know what a package is in MEAN. If you don't, read [http://mean.io/#!/docs this].&lt;br /&gt;
* Try creating a package named myPackage by typing: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; mean package myPackage;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Locate it inside the packages folder:&lt;br /&gt;
* Compare the structure of myPackage folder to that of the default app. Make sure you see both '''public''' and  '''server''' folders and their subfolders.&lt;br /&gt;
* Restart your app, make sure you can see a link to the newly created package.&lt;br /&gt;
&lt;br /&gt;
=A Closer Look at the App =&lt;br /&gt;
Take a look at the directory where you app resides, you will see two folders '''public''' and  '''server''', which contain code for the client side and server side respectively.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Models ==&lt;br /&gt;
&lt;br /&gt;
Open up article.js in /server/models&lt;br /&gt;
&lt;br /&gt;
MEAN is MVC on the client side and the server side.  Since the model is tied to the backend to MongoDB, you will only see the models folder on the server side, which is normal. &lt;br /&gt;
The models are mongoose models that's why we need to require mongoose (what the following line does):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
var mongoose = require('mongoose'), Schema = mongoose.Schema;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The following part then defines the schema:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
var ArticleSchema = new Schema({&lt;br /&gt;
    created: {&lt;br /&gt;
        type: Date,&lt;br /&gt;
        default: Date.now&lt;br /&gt;
    },&lt;br /&gt;
    title: {&lt;br /&gt;
        type: String,&lt;br /&gt;
        default: '',&lt;br /&gt;
        trim: true&lt;br /&gt;
    },&lt;br /&gt;
    content: {&lt;br /&gt;
        type: String,&lt;br /&gt;
        default: '',&lt;br /&gt;
        trim: true&lt;br /&gt;
    },&lt;br /&gt;
    user: {&lt;br /&gt;
        type: Schema.ObjectId,&lt;br /&gt;
        ref: 'User'&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The next part is validations, or criteria an object needs to pass before it can be saved to the DB. &lt;br /&gt;
The following code is to make sure that an article has a title:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
ArticleSchema.path('title').validate(function(title) {&lt;br /&gt;
    return title.length;&lt;br /&gt;
}, 'Title cannot be blank');&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, Mongoose allows us to define methods to our data objects as well. &lt;br /&gt;
These are called statics. From the Mongoose doc: Schemas not only define the structure of your document and casting of properties, they also define document instance methods, static Model methods, compound indexes and document lifecycle hooks called middleware.&lt;br /&gt;
The following code defines a method called load for the article schema:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
ArticleSchema.statics.load = function(id, cb) {&lt;br /&gt;
    this.findOne({&lt;br /&gt;
        _id: id&lt;br /&gt;
    }).populate('user', 'name username').exec(cb);&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have trouble understanding what the code does, review the Mongoose [http://mongoosejs.com/docs/index.html quick start] guide.&lt;br /&gt;
&lt;br /&gt;
=== Models Practice === &lt;br /&gt;
Define a schema for a model named '''Phone''', name it phone.js and save it in the corresponding folder in 'myPackage' (hint: /packages/myPackage/server/models/)&lt;br /&gt;
A product needs to have the following fields with specific types. Here is an example of a Phone object can be stored in the MongoDB:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;age&amp;quot;: 0, &lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;motorola-xoom-with-wi-fi&amp;quot;, &lt;br /&gt;
        &amp;quot;imageUrl&amp;quot;: &amp;quot;img/phones/motorola-xoom-with-wi-fi.0.jpg&amp;quot;, &lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;Motorola XOOM\u2122 with Wi-Fi&amp;quot;, &lt;br /&gt;
        &amp;quot;snippet&amp;quot;: &amp;quot;The Next, Next Generation\r\n\r\nExperience the future with Motorola XOOM wi.. d by Android 3.0 (Honeycomb).&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is taken from phones.json used by the AngularJS tutorial. If you have gone through the tutorial, you should have realized that instead of using a DB, json files were used to simplify the tutorial.&lt;br /&gt;
Find phones.json in /app/phones in the angular tutorial folder and try importing its content to MongoDB so you can use them in your current MEAN package.&lt;br /&gt;
&amp;lt;br/&amp;gt; Here is how (assuming mongod is running):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; mongo --shell // connect to mongo shell &lt;br /&gt;
&amp;gt; use mean-dev // switches to database used by mean.&lt;br /&gt;
&amp;gt; mongoimport --db mean-dev --collection phones --type json --file ''&amp;lt;path to phones.json&amp;gt;'' --jsonArray // imports json file to the DB&lt;br /&gt;
&amp;gt; show collections // check to see if phones are added to your database&lt;br /&gt;
&amp;gt; coll = db.phones // to see the content of the file&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Controllers ==&lt;br /&gt;
&lt;br /&gt;
You'll find a controllers folder on both the server side and the client (public) side.  &lt;br /&gt;
* The client side controllers are part of the Angular MVC scheme that contains client side logic and may issue requests to the server.&lt;br /&gt;
* The server side controllers deal with the models and requests from the client side.&lt;br /&gt;
&lt;br /&gt;
'''Server side:'''&lt;br /&gt;
&lt;br /&gt;
* Find articles.js in the controllers folder. Try to understand what each part does. &lt;br /&gt;
&lt;br /&gt;
'''Client side:''' open up articles.js in /articles/public/controllers&lt;br /&gt;
Compare the functions defined in ArticlesController, can you find the server side implementation of corresponding functions? &lt;br /&gt;
&lt;br /&gt;
Here is a diagram to help you under stand how this works:&lt;br /&gt;
&lt;br /&gt;
[[File:pic]]&lt;br /&gt;
&lt;br /&gt;
== Views &amp;amp; Routing ==&lt;br /&gt;
Even though typically views are implemented and used for the client end, routing happens on both ends.&lt;br /&gt;
&lt;br /&gt;
* Find articles.js in /server/routes&lt;br /&gt;
You'll see that it requires the articles controller and its methods for querying the database.&lt;br /&gt;
&lt;br /&gt;
The first section requires the articles controller, which defines different methods &lt;br /&gt;
&lt;br /&gt;
For example, code below tells the server to use a method named &amp;quot;all&amp;quot; in the articles controller when the url is pointed to /articles:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;   &lt;br /&gt;
app.route('/articles')&lt;br /&gt;
      .get(articles.all)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Go to http://localhost:3000/articles, what do you see? Does it make sense?&lt;br /&gt;
&lt;br /&gt;
Let's switch to the public folder where the views reside.  Go to articles/public/views, open up list.html: &amp;lt;br/&amp;gt;&lt;br /&gt;
The first line tells the framework that  ArticlesController is responsible for this particular view and when this view is loaded, use find() to initiate data binding.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html2strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;section data-ng-controller=&amp;quot;ArticlesController&amp;quot; data-ng-init=&amp;quot;find()&amp;quot;&amp;gt; &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Feel free to take a look at what find() does. Make sure you understand that what find() does is actually done by the backend, where a corresponding find() is written (as mentioned above).&lt;br /&gt;
Hopefully you have a better understanding of how these technologies all work together now.&lt;br /&gt;
&lt;br /&gt;
Review the AngularJS section if you have any questions regarding the view data binding.&lt;br /&gt;
&lt;br /&gt;
The view files in articles/views only defines the code for displaying the articles, where does the navigation bar gets defined.&lt;br /&gt;
The answer is in /public/system. &lt;br /&gt;
*The .html files in public/system/views provide a container/layout for the application. &lt;br /&gt;
For example, header.html includes the menu bar (displayed on the top of the page):&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;left pull-left&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;ul class=&amp;quot;navbar-nav nav&amp;quot;&amp;gt;&lt;br /&gt;
         &amp;lt;li data-ng-repeat=&amp;quot;item in menus.main&amp;quot; ui-route=&amp;quot;/{{item.link}}&amp;quot; ng-class=&amp;quot;{active: $uiRoute}&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;a mean-token=&amp;quot;item.link&amp;quot; ui-sref='{{item.link}}'&amp;gt;{{item.title}}&amp;lt;/a&amp;gt;&lt;br /&gt;
        &amp;lt;/li&amp;gt;&lt;br /&gt;
   &amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Try changing &amp;lt;nowiki&amp;gt;{{item.title}} &amp;lt;/nowiki&amp;gt; inside the &amp;lt;a&amp;gt; &amp;lt;/a&amp;gt;tags to &amp;quot;my articles&amp;quot; see what happens to the page.&lt;br /&gt;
* The ui-sref is &amp;quot;href&amp;quot; in ui-route, an AngularJS plugin, try changing &amp;lt;nowiki&amp;gt;{{item.link}}&amp;lt;/nowiki&amp;gt; to #!/myarticles, &lt;br /&gt;
* What happens to the application now? When you click on &amp;quot;my articles&amp;quot;?&lt;br /&gt;
&lt;br /&gt;
The page to articles is no longer served!&lt;br /&gt;
&lt;br /&gt;
But how does the framework know which page to serve given a certain url?  The file responsible for this (called routing in web development) is in public/articles/routes&lt;br /&gt;
&lt;br /&gt;
open up articles.js in this folder and find the line that specifies the routing scheme for /articles:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
            .state('all articles', {&lt;br /&gt;
                url: '/articles',&lt;br /&gt;
                templateUrl: 'public/articles/views/list.html',&lt;br /&gt;
                resolve: {&lt;br /&gt;
                    loggedin: checkLoggedin&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is ui-route's way of telling the server what to serve the page specified by the templateUrl when it sees &amp;quot;localhost:3000/#!/phones&amp;quot;. &lt;br /&gt;
The #! is a hash prefix used for MEAN to make ajax calls so make sure to include it when coding your views.&lt;br /&gt;
Now try changing the url to &amp;quot;/myarticles&amp;quot;, save and go back to your app, click on &amp;quot;my articles&amp;quot; now, what happens?&lt;br /&gt;
&lt;br /&gt;
*This is important if you want to customize your navigation bar and links. Just remember that each url needs an entry in the route file, in the format of the example above.&lt;br /&gt;
&lt;br /&gt;
= Practice = &lt;br /&gt;
&lt;br /&gt;
Can you implement a view in your myPackage to display all phones injected in the DB? &lt;br /&gt;
Hint: myPackage has the same file structure as the default app.&lt;/div&gt;</summary>
		<author><name>Vigo</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=1737</id>
		<title>Getting MEAN</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=1737"/>
		<updated>2014-05-12T01:00:25Z</updated>

		<summary type="html">&lt;p&gt;Vigo: /* Controllers */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Installation=&lt;br /&gt;
To install MEAN, make sure you already have all of the following components installed and configured correctly.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
'''1. Node.js''' (should come with npm) &amp;lt;br/&amp;gt;&lt;br /&gt;
To find out if you have node and npm, try checking their versions (may not be the same):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
node --version&lt;br /&gt;
v0.10.25&lt;br /&gt;
npm --version&lt;br /&gt;
1.3.24&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
IF you don't have node.js, install it [http://nodejs.org/ here].&lt;br /&gt;
&lt;br /&gt;
'''2. Bower'''&lt;br /&gt;
&lt;br /&gt;
Bower is a web application manager used by MEAN. To install bower, type the following command in your terminal: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;npm i -g bower&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''3. MongoDB'''&lt;br /&gt;
To install MongoDB, follow the instructions for your OS [http://docs.mongodb.org/manual/installation/ here].&lt;br /&gt;
&lt;br /&gt;
'''4. and finally, MEAN'''&lt;br /&gt;
In your terminal, type:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt; &amp;gt; sudo npm install -g meanio@latest &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* MEAN stack documentations are available [http://mean.io/#!/docs here]. They'll help you to get familiar with the file structure and idioms.&lt;br /&gt;
&lt;br /&gt;
=Running the Default App =&lt;br /&gt;
* Init and run an app. &lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; mean init myApp // create your first app&lt;br /&gt;
&amp;gt; cd myApp &lt;br /&gt;
&amp;gt; npm install // Install dependencies&lt;br /&gt;
&amp;gt; grunt // Launch mean&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Make sure MongoDB is connected and running (if you run into problems, refer to the section on MongoDB)&lt;br /&gt;
&lt;br /&gt;
* Go ahead and explore features of the default Article app (such as logging in, adding/deleting articles).&lt;br /&gt;
&lt;br /&gt;
=Generating a Package =&lt;br /&gt;
* By now you should know what a package is in MEAN. If you don't, read [http://mean.io/#!/docs this].&lt;br /&gt;
* Try creating a package named myPackage by typing: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; mean package myPackage;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Locate it inside the packages folder:&lt;br /&gt;
* Compare the structure of myPackage folder to that of the default app. Make sure you see both '''public''' and  '''server''' folders and their subfolders.&lt;br /&gt;
* Restart your app, make sure you can see a link to the newly created package.&lt;br /&gt;
&lt;br /&gt;
=A Closer Look at the App =&lt;br /&gt;
Take a look at the directory where you app resides, you will see two folders '''public''' and  '''server''', which contain code for the client side and server side respectively.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Models ==&lt;br /&gt;
&lt;br /&gt;
Open up article.js in /server/models&lt;br /&gt;
&lt;br /&gt;
MEAN is MVC on the client side and the server side.  Since the model is tied to the backend to MongoDB, you will only see the models folder on the server side, which is normal. &lt;br /&gt;
The models are mongoose models that's why we need to require mongoose (what the following line does):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
var mongoose = require('mongoose'), Schema = mongoose.Schema;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The following part then defines the schema:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
var ArticleSchema = new Schema({&lt;br /&gt;
    created: {&lt;br /&gt;
        type: Date,&lt;br /&gt;
        default: Date.now&lt;br /&gt;
    },&lt;br /&gt;
    title: {&lt;br /&gt;
        type: String,&lt;br /&gt;
        default: '',&lt;br /&gt;
        trim: true&lt;br /&gt;
    },&lt;br /&gt;
    content: {&lt;br /&gt;
        type: String,&lt;br /&gt;
        default: '',&lt;br /&gt;
        trim: true&lt;br /&gt;
    },&lt;br /&gt;
    user: {&lt;br /&gt;
        type: Schema.ObjectId,&lt;br /&gt;
        ref: 'User'&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The next part is validations, or criteria an object needs to pass before it can be saved to the DB. &lt;br /&gt;
The following code is to make sure that an article has a title:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
ArticleSchema.path('title').validate(function(title) {&lt;br /&gt;
    return title.length;&lt;br /&gt;
}, 'Title cannot be blank');&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, Mongoose allows us to define methods to our data objects as well. &lt;br /&gt;
These are called statics. From the Mongoose doc: Schemas not only define the structure of your document and casting of properties, they also define document instance methods, static Model methods, compound indexes and document lifecycle hooks called middleware.&lt;br /&gt;
The following code defines a method called load for the article schema:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
ArticleSchema.statics.load = function(id, cb) {&lt;br /&gt;
    this.findOne({&lt;br /&gt;
        _id: id&lt;br /&gt;
    }).populate('user', 'name username').exec(cb);&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have trouble understanding what the code does, review the Mongoose [http://mongoosejs.com/docs/index.html quick start] guide.&lt;br /&gt;
&lt;br /&gt;
=== Models Practice === &lt;br /&gt;
Define a schema for a model named '''Phone''', name it phone.js and save it in the corresponding folder in 'myPackage' (hint: /packages/myPackage/server/models/)&lt;br /&gt;
A product needs to have the following fields with specific types. Here is an example of a Phone object can be stored in the MongoDB:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;age&amp;quot;: 0, &lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;motorola-xoom-with-wi-fi&amp;quot;, &lt;br /&gt;
        &amp;quot;imageUrl&amp;quot;: &amp;quot;img/phones/motorola-xoom-with-wi-fi.0.jpg&amp;quot;, &lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;Motorola XOOM\u2122 with Wi-Fi&amp;quot;, &lt;br /&gt;
        &amp;quot;snippet&amp;quot;: &amp;quot;The Next, Next Generation\r\n\r\nExperience the future with Motorola XOOM wi.. d by Android 3.0 (Honeycomb).&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is taken from phones.json used by the AngularJS tutorial. If you have gone through the tutorial, you should have realized that instead of using a DB, json files were used to simplify the tutorial.&lt;br /&gt;
Find phones.json in /app/phones in the angular tutorial folder and try importing its content to MongoDB so you can use them in your current MEAN package.&lt;br /&gt;
&amp;lt;br/&amp;gt; Here is how (assuming mongod is running):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; mongo --shell // connect to mongo shell &lt;br /&gt;
&amp;gt; use mean-dev // switches to database used by mean.&lt;br /&gt;
&amp;gt; mongoimport --db mean-dev --collection phones --type json --file ''&amp;lt;path to phones.json&amp;gt;'' --jsonArray // imports json file to the DB&lt;br /&gt;
&amp;gt; show collections // check to see if phones are added to your database&lt;br /&gt;
&amp;gt; coll = db.phones // to see the content of the file&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Controllers ==&lt;br /&gt;
&lt;br /&gt;
You'll find a controllers folder on both the server side and the client (public) side.  &lt;br /&gt;
* The client side controllers are part of the Angular MVC scheme that contains client side logic and may issue requests to the server.&lt;br /&gt;
* The server side controllers deal with the models and requests from the client side.&lt;br /&gt;
&lt;br /&gt;
'''Server side:'''&lt;br /&gt;
&lt;br /&gt;
* Find articles.js in the controllers folder. Try to understand what each part does. &lt;br /&gt;
&lt;br /&gt;
'''Client side:''' open up articles.js in /articles/public/controllers&lt;br /&gt;
Compare the functions defined in ArticlesController, can you find the server side implementation of corresponding functions? &lt;br /&gt;
&lt;br /&gt;
Here is a diagram to help you under stand how this works:&lt;br /&gt;
&lt;br /&gt;
[[File:pic]]&lt;br /&gt;
&lt;br /&gt;
== Views &amp;amp; Routing ==&lt;br /&gt;
Let's switch to the public folder where the views reside. &lt;br /&gt;
&lt;br /&gt;
Go to public/articles/views, open up list.html:&lt;br /&gt;
The first line tells the framework that  ArticlesController is responsible for this particular view and when this view is loaded, use find() to initiate data binding.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;section data-ng-controller=&amp;quot;ArticlesController&amp;quot; data-ng-init=&amp;quot;find()&amp;quot;&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Feel free to take a look at what find() does. Make sure you understand that what find() does is actually done by the backend, where a corresponding find() is written (as mentioned above).&lt;br /&gt;
Hopefully you have a better understanding of how these technologies all work together now.&lt;br /&gt;
&lt;br /&gt;
Review the AngularJS section if you have any questions regarding the view data binding.&lt;br /&gt;
&lt;br /&gt;
The view files in articles/views only defines the code for displaying the articles, where does the navigation bar gets defined.&lt;br /&gt;
The answer is in /public/system. &lt;br /&gt;
*The .html files in public/system/views provide a container/layout for the application. &lt;br /&gt;
For example, header.html includes the menu bar (displayed on the top of the page):&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;left pull-left&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;ul class=&amp;quot;navbar-nav nav&amp;quot;&amp;gt;&lt;br /&gt;
         &amp;lt;li data-ng-repeat=&amp;quot;item in menus.main&amp;quot; ui-route=&amp;quot;/{{item.link}}&amp;quot; ng-class=&amp;quot;{active: $uiRoute}&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;a mean-token=&amp;quot;item.link&amp;quot; ui-sref='{{item.link}}'&amp;gt;{{item.title}}&amp;lt;/a&amp;gt;&lt;br /&gt;
        &amp;lt;/li&amp;gt;&lt;br /&gt;
   &amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Try changing &amp;lt;nowiki&amp;gt;{{item.title}} &amp;lt;/nowiki&amp;gt; inside the &amp;lt;a&amp;gt; &amp;lt;/a&amp;gt;tags to &amp;quot;my articles&amp;quot; see what happens to the page.&lt;br /&gt;
* The ui-sref is &amp;quot;href&amp;quot; in ui-route, an AngularJS plugin, try changing &amp;lt;nowiki&amp;gt;{{item.link}}&amp;lt;/nowiki&amp;gt; to #!/myarticles, &lt;br /&gt;
* What happens to the application now? When you click on &amp;quot;my articles&amp;quot;?&lt;br /&gt;
&lt;br /&gt;
The page to articles is no longer served!&lt;br /&gt;
&lt;br /&gt;
But how does the framework know which page to serve given a certain url?  The file responsible for this (called routing in web development) is in public/articles/routes&lt;br /&gt;
&lt;br /&gt;
open up articles.js in this folder and find the line that specifies the routing scheme for /articles:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
            .state('all articles', {&lt;br /&gt;
                url: '/articles',&lt;br /&gt;
                templateUrl: 'public/articles/views/list.html',&lt;br /&gt;
                resolve: {&lt;br /&gt;
                    loggedin: checkLoggedin&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is ui-route's way of telling the server what to serve the page specified by the templateUrl when it sees &amp;quot;localhost:3000/#!/phones&amp;quot;. &lt;br /&gt;
The #! is a hash prefix used for MEAN to make ajax calls so make sure to include it when coding your views.&lt;br /&gt;
Now try changing the url to &amp;quot;/myarticles&amp;quot;, save and go back to your app, click on &amp;quot;my articles&amp;quot; now, what happens?&lt;br /&gt;
&lt;br /&gt;
*This is important if you want to customize your navigation bar and links. Just remember that each url needs an entry in the route file, in the format of the example above.&lt;br /&gt;
&lt;br /&gt;
= Practice = &lt;br /&gt;
&lt;br /&gt;
Can you implement a view in your myPackage to display all phones injected in the DB? &lt;br /&gt;
Hint: myPackage has the same file structure as the default app.&lt;/div&gt;</summary>
		<author><name>Vigo</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=1736</id>
		<title>Getting MEAN</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=1736"/>
		<updated>2014-05-12T00:56:56Z</updated>

		<summary type="html">&lt;p&gt;Vigo: /* Controllers */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Installation=&lt;br /&gt;
To install MEAN, make sure you already have all of the following components installed and configured correctly.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
'''1. Node.js''' (should come with npm) &amp;lt;br/&amp;gt;&lt;br /&gt;
To find out if you have node and npm, try checking their versions (may not be the same):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
node --version&lt;br /&gt;
v0.10.25&lt;br /&gt;
npm --version&lt;br /&gt;
1.3.24&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
IF you don't have node.js, install it [http://nodejs.org/ here].&lt;br /&gt;
&lt;br /&gt;
'''2. Bower'''&lt;br /&gt;
&lt;br /&gt;
Bower is a web application manager used by MEAN. To install bower, type the following command in your terminal: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;npm i -g bower&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''3. MongoDB'''&lt;br /&gt;
To install MongoDB, follow the instructions for your OS [http://docs.mongodb.org/manual/installation/ here].&lt;br /&gt;
&lt;br /&gt;
'''4. and finally, MEAN'''&lt;br /&gt;
In your terminal, type:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt; &amp;gt; sudo npm install -g meanio@latest &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* MEAN stack documentations are available [http://mean.io/#!/docs here]. They'll help you to get familiar with the file structure and idioms.&lt;br /&gt;
&lt;br /&gt;
=Running the Default App =&lt;br /&gt;
* Init and run an app. &lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; mean init myApp // create your first app&lt;br /&gt;
&amp;gt; cd myApp &lt;br /&gt;
&amp;gt; npm install // Install dependencies&lt;br /&gt;
&amp;gt; grunt // Launch mean&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Make sure MongoDB is connected and running (if you run into problems, refer to the section on MongoDB)&lt;br /&gt;
&lt;br /&gt;
* Go ahead and explore features of the default Article app (such as logging in, adding/deleting articles).&lt;br /&gt;
&lt;br /&gt;
=Generating a Package =&lt;br /&gt;
* By now you should know what a package is in MEAN. If you don't, read [http://mean.io/#!/docs this].&lt;br /&gt;
* Try creating a package named myPackage by typing: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; mean package myPackage;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Locate it inside the packages folder:&lt;br /&gt;
* Compare the structure of myPackage folder to that of the default app. Make sure you see both '''public''' and  '''server''' folders and their subfolders.&lt;br /&gt;
* Restart your app, make sure you can see a link to the newly created package.&lt;br /&gt;
&lt;br /&gt;
=A Closer Look at the App =&lt;br /&gt;
Take a look at the directory where you app resides, you will see two folders '''public''' and  '''server''', which contain code for the client side and server side respectively.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Models ==&lt;br /&gt;
&lt;br /&gt;
Open up article.js in /server/models&lt;br /&gt;
&lt;br /&gt;
MEAN is MVC on the client side and the server side.  Since the model is tied to the backend to MongoDB, you will only see the models folder on the server side, which is normal. &lt;br /&gt;
The models are mongoose models that's why we need to require mongoose (what the following line does):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
var mongoose = require('mongoose'), Schema = mongoose.Schema;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The following part then defines the schema:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
var ArticleSchema = new Schema({&lt;br /&gt;
    created: {&lt;br /&gt;
        type: Date,&lt;br /&gt;
        default: Date.now&lt;br /&gt;
    },&lt;br /&gt;
    title: {&lt;br /&gt;
        type: String,&lt;br /&gt;
        default: '',&lt;br /&gt;
        trim: true&lt;br /&gt;
    },&lt;br /&gt;
    content: {&lt;br /&gt;
        type: String,&lt;br /&gt;
        default: '',&lt;br /&gt;
        trim: true&lt;br /&gt;
    },&lt;br /&gt;
    user: {&lt;br /&gt;
        type: Schema.ObjectId,&lt;br /&gt;
        ref: 'User'&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The next part is validations, or criteria an object needs to pass before it can be saved to the DB. &lt;br /&gt;
The following code is to make sure that an article has a title:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
ArticleSchema.path('title').validate(function(title) {&lt;br /&gt;
    return title.length;&lt;br /&gt;
}, 'Title cannot be blank');&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, Mongoose allows us to define methods to our data objects as well. &lt;br /&gt;
These are called statics. From the Mongoose doc: Schemas not only define the structure of your document and casting of properties, they also define document instance methods, static Model methods, compound indexes and document lifecycle hooks called middleware.&lt;br /&gt;
The following code defines a method called load for the article schema:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
ArticleSchema.statics.load = function(id, cb) {&lt;br /&gt;
    this.findOne({&lt;br /&gt;
        _id: id&lt;br /&gt;
    }).populate('user', 'name username').exec(cb);&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have trouble understanding what the code does, review the Mongoose [http://mongoosejs.com/docs/index.html quick start] guide.&lt;br /&gt;
&lt;br /&gt;
=== Models Practice === &lt;br /&gt;
Define a schema for a model named '''Phone''', name it phone.js and save it in the corresponding folder in 'myPackage' (hint: /packages/myPackage/server/models/)&lt;br /&gt;
A product needs to have the following fields with specific types. Here is an example of a Phone object can be stored in the MongoDB:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;age&amp;quot;: 0, &lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;motorola-xoom-with-wi-fi&amp;quot;, &lt;br /&gt;
        &amp;quot;imageUrl&amp;quot;: &amp;quot;img/phones/motorola-xoom-with-wi-fi.0.jpg&amp;quot;, &lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;Motorola XOOM\u2122 with Wi-Fi&amp;quot;, &lt;br /&gt;
        &amp;quot;snippet&amp;quot;: &amp;quot;The Next, Next Generation\r\n\r\nExperience the future with Motorola XOOM wi.. d by Android 3.0 (Honeycomb).&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is taken from phones.json used by the AngularJS tutorial. If you have gone through the tutorial, you should have realized that instead of using a DB, json files were used to simplify the tutorial.&lt;br /&gt;
Find phones.json in /app/phones in the angular tutorial folder and try importing its content to MongoDB so you can use them in your current MEAN package.&lt;br /&gt;
&amp;lt;br/&amp;gt; Here is how (assuming mongod is running):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; mongo --shell // connect to mongo shell &lt;br /&gt;
&amp;gt; use mean-dev // switches to database used by mean.&lt;br /&gt;
&amp;gt; mongoimport --db mean-dev --collection phones --type json --file ''&amp;lt;path to phones.json&amp;gt;'' --jsonArray // imports json file to the DB&lt;br /&gt;
&amp;gt; show collections // check to see if phones are added to your database&lt;br /&gt;
&amp;gt; coll = db.phones // to see the content of the file&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Controllers ==&lt;br /&gt;
&lt;br /&gt;
You'll find a controllers folder on both the server side and the client (public) side.  &lt;br /&gt;
* The client side controllers are part of the Angular MVC scheme that contains client side logic and may issue requests to the server.&lt;br /&gt;
* The server side controllers deal with the models and requests from the client side.&lt;br /&gt;
&lt;br /&gt;
'''Server side:'''&lt;br /&gt;
&lt;br /&gt;
* Find articles.js in the controllers folder. Try to understand what each part does. &lt;br /&gt;
* Find articles.js in /server/routes&lt;br /&gt;
You'll see that it requires the articles controller and its methods for querying the database.&lt;br /&gt;
&lt;br /&gt;
The first section requires the articles controller, which defines different methods &lt;br /&gt;
&lt;br /&gt;
For example:  &lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;   &lt;br /&gt;
app.route('/articles')&lt;br /&gt;
        .get(articles.all)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
tells the server to use a method named &amp;quot;all&amp;quot; in the articles controller when the url is pointed to /articles.&lt;br /&gt;
&lt;br /&gt;
*Go to http://localhost:3000/articles, what do you see? Does it make sense?&lt;br /&gt;
&lt;br /&gt;
'''Client side:''' open up articles.js in /articles/public/controllers&lt;br /&gt;
Compare the functions defined in ArticlesController, can you find the server side implementation of corresponding functions? &lt;br /&gt;
&lt;br /&gt;
Here is a diagram to help you under stand how this works:&lt;br /&gt;
&lt;br /&gt;
[[File:pic]]&lt;br /&gt;
&lt;br /&gt;
== Views &amp;amp; Routing ==&lt;br /&gt;
Let's switch to the public folder where the views reside. &lt;br /&gt;
&lt;br /&gt;
Go to public/articles/views, open up list.html:&lt;br /&gt;
The first line tells the framework that  ArticlesController is responsible for this particular view and when this view is loaded, use find() to initiate data binding.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;section data-ng-controller=&amp;quot;ArticlesController&amp;quot; data-ng-init=&amp;quot;find()&amp;quot;&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Feel free to take a look at what find() does. Make sure you understand that what find() does is actually done by the backend, where a corresponding find() is written (as mentioned above).&lt;br /&gt;
Hopefully you have a better understanding of how these technologies all work together now.&lt;br /&gt;
&lt;br /&gt;
Review the AngularJS section if you have any questions regarding the view data binding.&lt;br /&gt;
&lt;br /&gt;
The view files in articles/views only defines the code for displaying the articles, where does the navigation bar gets defined.&lt;br /&gt;
The answer is in /public/system. &lt;br /&gt;
*The .html files in public/system/views provide a container/layout for the application. &lt;br /&gt;
For example, header.html includes the menu bar (displayed on the top of the page):&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;left pull-left&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;ul class=&amp;quot;navbar-nav nav&amp;quot;&amp;gt;&lt;br /&gt;
         &amp;lt;li data-ng-repeat=&amp;quot;item in menus.main&amp;quot; ui-route=&amp;quot;/{{item.link}}&amp;quot; ng-class=&amp;quot;{active: $uiRoute}&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;a mean-token=&amp;quot;item.link&amp;quot; ui-sref='{{item.link}}'&amp;gt;{{item.title}}&amp;lt;/a&amp;gt;&lt;br /&gt;
        &amp;lt;/li&amp;gt;&lt;br /&gt;
   &amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Try changing &amp;lt;nowiki&amp;gt;{{item.title}} &amp;lt;/nowiki&amp;gt; inside the &amp;lt;a&amp;gt; &amp;lt;/a&amp;gt;tags to &amp;quot;my articles&amp;quot; see what happens to the page.&lt;br /&gt;
* The ui-sref is &amp;quot;href&amp;quot; in ui-route, an AngularJS plugin, try changing &amp;lt;nowiki&amp;gt;{{item.link}}&amp;lt;/nowiki&amp;gt; to #!/myarticles, &lt;br /&gt;
* What happens to the application now? When you click on &amp;quot;my articles&amp;quot;?&lt;br /&gt;
&lt;br /&gt;
The page to articles is no longer served!&lt;br /&gt;
&lt;br /&gt;
But how does the framework know which page to serve given a certain url?  The file responsible for this (called routing in web development) is in public/articles/routes&lt;br /&gt;
&lt;br /&gt;
open up articles.js in this folder and find the line that specifies the routing scheme for /articles:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
            .state('all articles', {&lt;br /&gt;
                url: '/articles',&lt;br /&gt;
                templateUrl: 'public/articles/views/list.html',&lt;br /&gt;
                resolve: {&lt;br /&gt;
                    loggedin: checkLoggedin&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is ui-route's way of telling the server what to serve the page specified by the templateUrl when it sees &amp;quot;localhost:3000/#!/phones&amp;quot;. &lt;br /&gt;
The #! is a hash prefix used for MEAN to make ajax calls so make sure to include it when coding your views.&lt;br /&gt;
Now try changing the url to &amp;quot;/myarticles&amp;quot;, save and go back to your app, click on &amp;quot;my articles&amp;quot; now, what happens?&lt;br /&gt;
&lt;br /&gt;
*This is important if you want to customize your navigation bar and links. Just remember that each url needs an entry in the route file, in the format of the example above.&lt;br /&gt;
&lt;br /&gt;
= Practice = &lt;br /&gt;
&lt;br /&gt;
Can you implement a view in your myPackage to display all phones injected in the DB? &lt;br /&gt;
Hint: myPackage has the same file structure as the default app.&lt;/div&gt;</summary>
		<author><name>Vigo</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=1735</id>
		<title>Getting MEAN</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=1735"/>
		<updated>2014-05-12T00:10:39Z</updated>

		<summary type="html">&lt;p&gt;Vigo: /* Models */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Installation=&lt;br /&gt;
To install MEAN, make sure you already have all of the following components installed and configured correctly.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
'''1. Node.js''' (should come with npm) &amp;lt;br/&amp;gt;&lt;br /&gt;
To find out if you have node and npm, try checking their versions (may not be the same):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
node --version&lt;br /&gt;
v0.10.25&lt;br /&gt;
npm --version&lt;br /&gt;
1.3.24&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
IF you don't have node.js, install it [http://nodejs.org/ here].&lt;br /&gt;
&lt;br /&gt;
'''2. Bower'''&lt;br /&gt;
&lt;br /&gt;
Bower is a web application manager used by MEAN. To install bower, type the following command in your terminal: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;npm i -g bower&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''3. MongoDB'''&lt;br /&gt;
To install MongoDB, follow the instructions for your OS [http://docs.mongodb.org/manual/installation/ here].&lt;br /&gt;
&lt;br /&gt;
'''4. and finally, MEAN'''&lt;br /&gt;
In your terminal, type:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt; &amp;gt; sudo npm install -g meanio@latest &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* MEAN stack documentations are available [http://mean.io/#!/docs here]. They'll help you to get familiar with the file structure and idioms.&lt;br /&gt;
&lt;br /&gt;
=Running the Default App =&lt;br /&gt;
* Init and run an app. &lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; mean init myApp // create your first app&lt;br /&gt;
&amp;gt; cd myApp &lt;br /&gt;
&amp;gt; npm install // Install dependencies&lt;br /&gt;
&amp;gt; grunt // Launch mean&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Make sure MongoDB is connected and running (if you run into problems, refer to the section on MongoDB)&lt;br /&gt;
&lt;br /&gt;
* Go ahead and explore features of the default Article app (such as logging in, adding/deleting articles).&lt;br /&gt;
&lt;br /&gt;
=Generating a Package =&lt;br /&gt;
* By now you should know what a package is in MEAN. If you don't, read [http://mean.io/#!/docs this].&lt;br /&gt;
* Try creating a package named myPackage by typing: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; mean package myPackage;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Locate it inside the packages folder:&lt;br /&gt;
* Compare the structure of myPackage folder to that of the default app. Make sure you see both '''public''' and  '''server''' folders and their subfolders.&lt;br /&gt;
* Restart your app, make sure you can see a link to the newly created package.&lt;br /&gt;
&lt;br /&gt;
=A Closer Look at the App =&lt;br /&gt;
Take a look at the directory where you app resides, you will see two folders '''public''' and  '''server''', which contain code for the client side and server side respectively.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Models ==&lt;br /&gt;
&lt;br /&gt;
Open up article.js in /server/models&lt;br /&gt;
&lt;br /&gt;
MEAN is MVC on the client side and the server side.  Since the model is tied to the backend to MongoDB, you will only see the models folder on the server side, which is normal. &lt;br /&gt;
The models are mongoose models that's why we need to require mongoose (what the following line does):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
var mongoose = require('mongoose'), Schema = mongoose.Schema;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The following part then defines the schema:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
var ArticleSchema = new Schema({&lt;br /&gt;
    created: {&lt;br /&gt;
        type: Date,&lt;br /&gt;
        default: Date.now&lt;br /&gt;
    },&lt;br /&gt;
    title: {&lt;br /&gt;
        type: String,&lt;br /&gt;
        default: '',&lt;br /&gt;
        trim: true&lt;br /&gt;
    },&lt;br /&gt;
    content: {&lt;br /&gt;
        type: String,&lt;br /&gt;
        default: '',&lt;br /&gt;
        trim: true&lt;br /&gt;
    },&lt;br /&gt;
    user: {&lt;br /&gt;
        type: Schema.ObjectId,&lt;br /&gt;
        ref: 'User'&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The next part is validations, or criteria an object needs to pass before it can be saved to the DB. &lt;br /&gt;
The following code is to make sure that an article has a title:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
ArticleSchema.path('title').validate(function(title) {&lt;br /&gt;
    return title.length;&lt;br /&gt;
}, 'Title cannot be blank');&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, Mongoose allows us to define methods to our data objects as well. &lt;br /&gt;
These are called statics. From the Mongoose doc: Schemas not only define the structure of your document and casting of properties, they also define document instance methods, static Model methods, compound indexes and document lifecycle hooks called middleware.&lt;br /&gt;
The following code defines a method called load for the article schema:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
ArticleSchema.statics.load = function(id, cb) {&lt;br /&gt;
    this.findOne({&lt;br /&gt;
        _id: id&lt;br /&gt;
    }).populate('user', 'name username').exec(cb);&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have trouble understanding what the code does, review the Mongoose [http://mongoosejs.com/docs/index.html quick start] guide.&lt;br /&gt;
&lt;br /&gt;
=== Models Practice === &lt;br /&gt;
Define a schema for a model named '''Phone''', name it phone.js and save it in the corresponding folder in 'myPackage' (hint: /packages/myPackage/server/models/)&lt;br /&gt;
A product needs to have the following fields with specific types. Here is an example of a Phone object can be stored in the MongoDB:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;age&amp;quot;: 0, &lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;motorola-xoom-with-wi-fi&amp;quot;, &lt;br /&gt;
        &amp;quot;imageUrl&amp;quot;: &amp;quot;img/phones/motorola-xoom-with-wi-fi.0.jpg&amp;quot;, &lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;Motorola XOOM\u2122 with Wi-Fi&amp;quot;, &lt;br /&gt;
        &amp;quot;snippet&amp;quot;: &amp;quot;The Next, Next Generation\r\n\r\nExperience the future with Motorola XOOM wi.. d by Android 3.0 (Honeycomb).&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is taken from phones.json used by the AngularJS tutorial. If you have gone through the tutorial, you should have realized that instead of using a DB, json files were used to simplify the tutorial.&lt;br /&gt;
Find phones.json in /app/phones in the angular tutorial folder and try importing its content to MongoDB so you can use them in your current MEAN package.&lt;br /&gt;
&amp;lt;br/&amp;gt; Here is how (assuming mongod is running):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; mongo --shell // connect to mongo shell &lt;br /&gt;
&amp;gt; use mean-dev // switches to database used by mean.&lt;br /&gt;
&amp;gt; mongoimport --db mean-dev --collection phones --type json --file ''&amp;lt;path to phones.json&amp;gt;'' --jsonArray // imports json file to the DB&lt;br /&gt;
&amp;gt; show collections // check to see if phones are added to your database&lt;br /&gt;
&amp;gt; coll = db.phones // to see the content of the file&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Controllers ==&lt;br /&gt;
&lt;br /&gt;
You'll find a controllers folder on both the server side and the client side.  &lt;br /&gt;
* The client side controllers are part of the Angular MVC scheme that contains client side logic and may issue requests to the server.&lt;br /&gt;
* The server side controllers deal with the models and requests from the client side.&lt;br /&gt;
&lt;br /&gt;
'''Server side:'''&lt;br /&gt;
&lt;br /&gt;
* Find articles.js in the controllers folder. Try to understand what each part does. &lt;br /&gt;
* Find articles.js in /server/routes/middlewares &lt;br /&gt;
You'll see that it requires the articles controller and its methods for querying the database.&lt;br /&gt;
&lt;br /&gt;
The first section requires the articles controller, which defines different methods &lt;br /&gt;
&lt;br /&gt;
For example:     &lt;br /&gt;
app.route('/articles')&lt;br /&gt;
        .get(articles.all)&lt;br /&gt;
tells the server to use a method named &amp;quot;all&amp;quot; in the articles controller when the url is pointed to /articles.&lt;br /&gt;
&lt;br /&gt;
*Go to http://localhost:3000/articles, what do you see? Does it make sense?&lt;br /&gt;
&lt;br /&gt;
'''Client side:''' open up articles.js in /public/articles/controllers&lt;br /&gt;
Compare the functions defined in ArticlesController, can you find the corresponding functions on the server side implementation of articles controller? &lt;br /&gt;
&lt;br /&gt;
Here is a diagram to help you under stand how this works:&lt;br /&gt;
&lt;br /&gt;
[[File:pic]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Views &amp;amp; Routing ==&lt;br /&gt;
Let's switch to the public folder where the views reside. &lt;br /&gt;
&lt;br /&gt;
Go to public/articles/views, open up list.html:&lt;br /&gt;
The first line tells the framework that  ArticlesController is responsible for this particular view and when this view is loaded, use find() to initiate data binding.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;section data-ng-controller=&amp;quot;ArticlesController&amp;quot; data-ng-init=&amp;quot;find()&amp;quot;&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Feel free to take a look at what find() does. Make sure you understand that what find() does is actually done by the backend, where a corresponding find() is written (as mentioned above).&lt;br /&gt;
Hopefully you have a better understanding of how these technologies all work together now.&lt;br /&gt;
&lt;br /&gt;
Review the AngularJS section if you have any questions regarding the view data binding.&lt;br /&gt;
&lt;br /&gt;
The view files in articles/views only defines the code for displaying the articles, where does the navigation bar gets defined.&lt;br /&gt;
The answer is in /public/system. &lt;br /&gt;
*The .html files in public/system/views provide a container/layout for the application. &lt;br /&gt;
For example, header.html includes the menu bar (displayed on the top of the page):&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;left pull-left&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;ul class=&amp;quot;navbar-nav nav&amp;quot;&amp;gt;&lt;br /&gt;
         &amp;lt;li data-ng-repeat=&amp;quot;item in menus.main&amp;quot; ui-route=&amp;quot;/{{item.link}}&amp;quot; ng-class=&amp;quot;{active: $uiRoute}&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;a mean-token=&amp;quot;item.link&amp;quot; ui-sref='{{item.link}}'&amp;gt;{{item.title}}&amp;lt;/a&amp;gt;&lt;br /&gt;
        &amp;lt;/li&amp;gt;&lt;br /&gt;
   &amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Try changing &amp;lt;nowiki&amp;gt;{{item.title}} &amp;lt;/nowiki&amp;gt; inside the &amp;lt;a&amp;gt; &amp;lt;/a&amp;gt;tags to &amp;quot;my articles&amp;quot; see what happens to the page.&lt;br /&gt;
* The ui-sref is &amp;quot;href&amp;quot; in ui-route, an AngularJS plugin, try changing &amp;lt;nowiki&amp;gt;{{item.link}}&amp;lt;/nowiki&amp;gt; to #!/myarticles, &lt;br /&gt;
* What happens to the application now? When you click on &amp;quot;my articles&amp;quot;?&lt;br /&gt;
&lt;br /&gt;
The page to articles is no longer served!&lt;br /&gt;
&lt;br /&gt;
But how does the framework know which page to serve given a certain url?  The file responsible for this (called routing in web development) is in public/articles/routes&lt;br /&gt;
&lt;br /&gt;
open up articles.js in this folder and find the line that specifies the routing scheme for /articles:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
            .state('all articles', {&lt;br /&gt;
                url: '/articles',&lt;br /&gt;
                templateUrl: 'public/articles/views/list.html',&lt;br /&gt;
                resolve: {&lt;br /&gt;
                    loggedin: checkLoggedin&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is ui-route's way of telling the server what to serve the page specified by the templateUrl when it sees &amp;quot;localhost:3000/#!/phones&amp;quot;. &lt;br /&gt;
The #! is a hash prefix used for MEAN to make ajax calls so make sure to include it when coding your views.&lt;br /&gt;
Now try changing the url to &amp;quot;/myarticles&amp;quot;, save and go back to your app, click on &amp;quot;my articles&amp;quot; now, what happens?&lt;br /&gt;
&lt;br /&gt;
*This is important if you want to customize your navigation bar and links. Just remember that each url needs an entry in the route file, in the format of the example above.&lt;br /&gt;
&lt;br /&gt;
= Practice = &lt;br /&gt;
&lt;br /&gt;
Can you implement a view in your myPackage to display all phones injected in the DB? &lt;br /&gt;
Hint: myPackage has the same file structure as the default app.&lt;/div&gt;</summary>
		<author><name>Vigo</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=1734</id>
		<title>Getting MEAN</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=1734"/>
		<updated>2014-05-11T23:55:04Z</updated>

		<summary type="html">&lt;p&gt;Vigo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Installation=&lt;br /&gt;
To install MEAN, make sure you already have all of the following components installed and configured correctly.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
'''1. Node.js''' (should come with npm) &amp;lt;br/&amp;gt;&lt;br /&gt;
To find out if you have node and npm, try checking their versions (may not be the same):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
node --version&lt;br /&gt;
v0.10.25&lt;br /&gt;
npm --version&lt;br /&gt;
1.3.24&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
IF you don't have node.js, install it [http://nodejs.org/ here].&lt;br /&gt;
&lt;br /&gt;
'''2. Bower'''&lt;br /&gt;
&lt;br /&gt;
Bower is a web application manager used by MEAN. To install bower, type the following command in your terminal: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;npm i -g bower&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''3. MongoDB'''&lt;br /&gt;
To install MongoDB, follow the instructions for your OS [http://docs.mongodb.org/manual/installation/ here].&lt;br /&gt;
&lt;br /&gt;
'''4. and finally, MEAN'''&lt;br /&gt;
In your terminal, type:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt; &amp;gt; sudo npm install -g meanio@latest &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* MEAN stack documentations are available [http://mean.io/#!/docs here]. They'll help you to get familiar with the file structure and idioms.&lt;br /&gt;
&lt;br /&gt;
=Running the Default App =&lt;br /&gt;
* Init and run an app. &lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; mean init myApp // create your first app&lt;br /&gt;
&amp;gt; cd myApp &lt;br /&gt;
&amp;gt; npm install // Install dependencies&lt;br /&gt;
&amp;gt; grunt // Launch mean&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Make sure MongoDB is connected and running (if you run into problems, refer to the section on MongoDB)&lt;br /&gt;
&lt;br /&gt;
* Go ahead and explore features of the default Article app (such as logging in, adding/deleting articles).&lt;br /&gt;
&lt;br /&gt;
=Generating a Package =&lt;br /&gt;
* By now you should know what a package is in MEAN. If you don't, read [http://mean.io/#!/docs this].&lt;br /&gt;
* Try creating a package named myPackage by typing: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; mean package myPackage;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Locate it inside the packages folder:&lt;br /&gt;
* Compare the structure of myPackage folder to that of the default app. Make sure you see both '''public''' and  '''server''' folders and their subfolders.&lt;br /&gt;
* Restart your app, make sure you can see a link to the newly created package.&lt;br /&gt;
&lt;br /&gt;
=A Closer Look at the App =&lt;br /&gt;
Take a look at the directory where you app resides, you will see two folders '''public''' and  '''server''', which contain code for the client side and server side respectively.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Models ==&lt;br /&gt;
&lt;br /&gt;
Open up article.js in /server/models&lt;br /&gt;
&lt;br /&gt;
MEAN is MVC on the client side and the server side.  Since the model is tied to the backend to MongoDB, you will only see the models folder on the server side, which is normal. &lt;br /&gt;
The models are mongoose models that's why we need to require mongoose (what the following line does):&lt;br /&gt;
&lt;br /&gt;
var mongoose = require('mongoose'), Schema = mongoose.Schema;&lt;br /&gt;
&lt;br /&gt;
The following part then defines the schema:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
var ArticleSchema = new Schema({&lt;br /&gt;
    created: {&lt;br /&gt;
        type: Date,&lt;br /&gt;
        default: Date.now&lt;br /&gt;
    },&lt;br /&gt;
    title: {&lt;br /&gt;
        type: String,&lt;br /&gt;
        default: '',&lt;br /&gt;
        trim: true&lt;br /&gt;
    },&lt;br /&gt;
    content: {&lt;br /&gt;
        type: String,&lt;br /&gt;
        default: '',&lt;br /&gt;
        trim: true&lt;br /&gt;
    },&lt;br /&gt;
    user: {&lt;br /&gt;
        type: Schema.ObjectId,&lt;br /&gt;
        ref: 'User'&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The next part is validations, or criteria an object needs to pass before it can be saved to the DB. &lt;br /&gt;
The following code is to make sure that an article has a title:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
ArticleSchema.path('title').validate(function(title) {&lt;br /&gt;
    return title.length;&lt;br /&gt;
}, 'Title cannot be blank');&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, Mongoose allows us to define methods to our data objects as well. &lt;br /&gt;
These are called statics. From the Mongoose doc: Schemas not only define the structure of your document and casting of properties, they also define document instance methods, static Model methods, compound indexes and document lifecycle hooks called middleware.&lt;br /&gt;
The following code defines a method called load for the article schema:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
ArticleSchema.statics.load = function(id, cb) {&lt;br /&gt;
    this.findOne({&lt;br /&gt;
        _id: id&lt;br /&gt;
    }).populate('user', 'name username').exec(cb);&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have trouble understanding what the code does, review the Mongoose [http://mongoosejs.com/docs/index.html quick start] guide.&lt;br /&gt;
&lt;br /&gt;
=== Models Practice === &lt;br /&gt;
Define a schema for a model named '''Phone''', name it phone.js and save it in the corresponding folder in 'myPackage' (hint: /packages/myPackage/server/models/)&lt;br /&gt;
A product needs to have the following fields with specific types. Here is an example of a Phone object can be stored in the MongoDB:&lt;br /&gt;
&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;age&amp;quot;: 0, &lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;motorola-xoom-with-wi-fi&amp;quot;, &lt;br /&gt;
        &amp;quot;imageUrl&amp;quot;: &amp;quot;img/phones/motorola-xoom-with-wi-fi.0.jpg&amp;quot;, &lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;Motorola XOOM\u2122 with Wi-Fi&amp;quot;, &lt;br /&gt;
        &amp;quot;snippet&amp;quot;: &amp;quot;The Next, Next Generation\r\n\r\nExperience the future with Motorola XOOM with Wi-Fi, the world's first tablet powered by Android 3.0 (Honeycomb).&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
This is taken from phones.json used by the AngularJS tutorial. If you have gone through the tutorial, you should have realized that instead of using a DB, json files were used to simplify the tutorial.&lt;br /&gt;
Find phones.json in /app/phones in the angular tutorial folder and try importing its content to MongoDB so you can use them in your current MEAN package.&lt;br /&gt;
&lt;br /&gt;
*Run '''mongod''' and connect to mongo shell (mongo --shell), then type &amp;quot;use mean-dev&amp;quot; to switch to database used by mean.&lt;br /&gt;
*Type  mongoimport --db mean-dev --collection phones --type json --file ''&amp;lt;path to phones.json&amp;gt;'' --jsonArray&lt;br /&gt;
*Type show collections to see if phones are added to your database, type coll = db.phones to see the content of the file.&lt;br /&gt;
&lt;br /&gt;
== Controllers ==&lt;br /&gt;
&lt;br /&gt;
You'll find a controllers folder on both the server side and the client side.  &lt;br /&gt;
* The client side controllers are part of the Angular MVC scheme that contains client side logic and may issue requests to the server.&lt;br /&gt;
* The server side controllers deal with the models and requests from the client side.&lt;br /&gt;
&lt;br /&gt;
'''Server side:'''&lt;br /&gt;
&lt;br /&gt;
* Find articles.js in the controllers folder. Try to understand what each part does. &lt;br /&gt;
* Find articles.js in /server/routes/middlewares &lt;br /&gt;
You'll see that it requires the articles controller and its methods for querying the database.&lt;br /&gt;
&lt;br /&gt;
The first section requires the articles controller, which defines different methods &lt;br /&gt;
&lt;br /&gt;
For example:     &lt;br /&gt;
app.route('/articles')&lt;br /&gt;
        .get(articles.all)&lt;br /&gt;
tells the server to use a method named &amp;quot;all&amp;quot; in the articles controller when the url is pointed to /articles.&lt;br /&gt;
&lt;br /&gt;
*Go to http://localhost:3000/articles, what do you see? Does it make sense?&lt;br /&gt;
&lt;br /&gt;
'''Client side:''' open up articles.js in /public/articles/controllers&lt;br /&gt;
Compare the functions defined in ArticlesController, can you find the corresponding functions on the server side implementation of articles controller? &lt;br /&gt;
&lt;br /&gt;
Here is a diagram to help you under stand how this works:&lt;br /&gt;
&lt;br /&gt;
[[File:pic]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Views &amp;amp; Routing ==&lt;br /&gt;
Let's switch to the public folder where the views reside. &lt;br /&gt;
&lt;br /&gt;
Go to public/articles/views, open up list.html:&lt;br /&gt;
The first line tells the framework that  ArticlesController is responsible for this particular view and when this view is loaded, use find() to initiate data binding.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;section data-ng-controller=&amp;quot;ArticlesController&amp;quot; data-ng-init=&amp;quot;find()&amp;quot;&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Feel free to take a look at what find() does. Make sure you understand that what find() does is actually done by the backend, where a corresponding find() is written (as mentioned above).&lt;br /&gt;
Hopefully you have a better understanding of how these technologies all work together now.&lt;br /&gt;
&lt;br /&gt;
Review the AngularJS section if you have any questions regarding the view data binding.&lt;br /&gt;
&lt;br /&gt;
The view files in articles/views only defines the code for displaying the articles, where does the navigation bar gets defined.&lt;br /&gt;
The answer is in /public/system. &lt;br /&gt;
*The .html files in public/system/views provide a container/layout for the application. &lt;br /&gt;
For example, header.html includes the menu bar (displayed on the top of the page):&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;left pull-left&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;ul class=&amp;quot;navbar-nav nav&amp;quot;&amp;gt;&lt;br /&gt;
         &amp;lt;li data-ng-repeat=&amp;quot;item in menus.main&amp;quot; ui-route=&amp;quot;/{{item.link}}&amp;quot; ng-class=&amp;quot;{active: $uiRoute}&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;a mean-token=&amp;quot;item.link&amp;quot; ui-sref='{{item.link}}'&amp;gt;{{item.title}}&amp;lt;/a&amp;gt;&lt;br /&gt;
        &amp;lt;/li&amp;gt;&lt;br /&gt;
   &amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Try changing &amp;lt;nowiki&amp;gt;{{item.title}} &amp;lt;/nowiki&amp;gt; inside the &amp;lt;a&amp;gt; &amp;lt;/a&amp;gt;tags to &amp;quot;my articles&amp;quot; see what happens to the page.&lt;br /&gt;
* The ui-sref is &amp;quot;href&amp;quot; in ui-route, an AngularJS plugin, try changing &amp;lt;nowiki&amp;gt;{{item.link}}&amp;lt;/nowiki&amp;gt; to #!/myarticles, &lt;br /&gt;
* What happens to the application now? When you click on &amp;quot;my articles&amp;quot;?&lt;br /&gt;
&lt;br /&gt;
The page to articles is no longer served!&lt;br /&gt;
&lt;br /&gt;
But how does the framework know which page to serve given a certain url?  The file responsible for this (called routing in web development) is in public/articles/routes&lt;br /&gt;
&lt;br /&gt;
open up articles.js in this folder and find the line that specifies the routing scheme for /articles:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
            .state('all articles', {&lt;br /&gt;
                url: '/articles',&lt;br /&gt;
                templateUrl: 'public/articles/views/list.html',&lt;br /&gt;
                resolve: {&lt;br /&gt;
                    loggedin: checkLoggedin&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is ui-route's way of telling the server what to serve the page specified by the templateUrl when it sees &amp;quot;localhost:3000/#!/phones&amp;quot;. &lt;br /&gt;
The #! is a hash prefix used for MEAN to make ajax calls so make sure to include it when coding your views.&lt;br /&gt;
Now try changing the url to &amp;quot;/myarticles&amp;quot;, save and go back to your app, click on &amp;quot;my articles&amp;quot; now, what happens?&lt;br /&gt;
&lt;br /&gt;
*This is important if you want to customize your navigation bar and links. Just remember that each url needs an entry in the route file, in the format of the example above.&lt;br /&gt;
&lt;br /&gt;
= Practice = &lt;br /&gt;
&lt;br /&gt;
Can you implement a view in your myPackage to display all phones injected in the DB? &lt;br /&gt;
Hint: myPackage has the same file structure as the default app.&lt;/div&gt;</summary>
		<author><name>Vigo</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=1733</id>
		<title>Getting MEAN</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=1733"/>
		<updated>2014-05-11T23:49:17Z</updated>

		<summary type="html">&lt;p&gt;Vigo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Installation=&lt;br /&gt;
To install MEAN, make sure you already have all of the following components installed and configured correctly.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
'''1. Node.js''' (should come with npm) &amp;lt;br/&amp;gt;&lt;br /&gt;
To find out if you have node and npm, try checking their versions (may not be the same):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
node --version&lt;br /&gt;
v0.10.25&lt;br /&gt;
npm --version&lt;br /&gt;
1.3.24&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
IF you don't have node.js, install it [http://nodejs.org/ here].&lt;br /&gt;
&lt;br /&gt;
'''2. Bower'''&lt;br /&gt;
&lt;br /&gt;
Bower is a web application manager used by MEAN. To install bower, type the following command in your terminal: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;npm i -g bower&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''3. MongoDB'''&lt;br /&gt;
To install MongoDB, follow the instructions for your OS [http://docs.mongodb.org/manual/installation/ here].&lt;br /&gt;
&lt;br /&gt;
'''4. and finally, MEAN'''&lt;br /&gt;
In your terminal, type:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt; &amp;gt; sudo npm install -g meanio@latest &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* MEAN stack documentations are available [http://mean.io/#!/docs here]. They'll help you to get familiar with the file structure and idioms.&lt;br /&gt;
&lt;br /&gt;
=Running the Default App =&lt;br /&gt;
* Init and run an app. &lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; mean init myApp // create your first app&lt;br /&gt;
&amp;gt; cd myApp &lt;br /&gt;
&amp;gt; npm install // Install dependencies&lt;br /&gt;
&amp;gt; grunt // Launch mean&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Make sure MongoDB is connected and running (if you run into problems, refer to the section on MongoDB)&lt;br /&gt;
&lt;br /&gt;
* Go ahead and explore features of the default Article app (such as logging in, adding/deleting articles).&lt;br /&gt;
&lt;br /&gt;
=Generating a Package =&lt;br /&gt;
* By now you should know what a package is in MEAN. If you don't, read [http://mean.io/#!/docs this].&lt;br /&gt;
* Try creating a package named myPackage by typing: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; mean package myPackage;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Locate it inside the packages folder:&lt;br /&gt;
* Compare the structure of myPackage folder to that of the default app. Make sure you see both '''public''' and  '''server''' folders and their subfolders.&lt;br /&gt;
* Restart your app, make sure you can see a link to the newly created package.&lt;br /&gt;
&lt;br /&gt;
=A Closer Look at the App =&lt;br /&gt;
Take a look at the directory where you app resides, you will see two folders '''public''' and  '''server''', which contain code for the client side and server side respectively.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Models ==&lt;br /&gt;
&lt;br /&gt;
Open up article.js in /server/models&lt;br /&gt;
&lt;br /&gt;
MEAN is MVC on the client side and the server side.  Since the model is tied to the backend to MongoDB, you will only see the models folder on the server side, which is normal. &lt;br /&gt;
The models are mongoose models that's why we need to require mongoose (what the following line does):&lt;br /&gt;
&lt;br /&gt;
var mongoose = require('mongoose'), Schema = mongoose.Schema;&lt;br /&gt;
&lt;br /&gt;
The following part then defines the schema:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
var ArticleSchema = new Schema({&lt;br /&gt;
    created: {&lt;br /&gt;
        type: Date,&lt;br /&gt;
        default: Date.now&lt;br /&gt;
    },&lt;br /&gt;
    title: {&lt;br /&gt;
        type: String,&lt;br /&gt;
        default: '',&lt;br /&gt;
        trim: true&lt;br /&gt;
    },&lt;br /&gt;
    content: {&lt;br /&gt;
        type: String,&lt;br /&gt;
        default: '',&lt;br /&gt;
        trim: true&lt;br /&gt;
    },&lt;br /&gt;
    user: {&lt;br /&gt;
        type: Schema.ObjectId,&lt;br /&gt;
        ref: 'User'&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The next part is validations, or criteria an object needs to pass before it can be saved to the DB. &lt;br /&gt;
The following code is to make sure that an article has a title:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
ArticleSchema.path('title').validate(function(title) {&lt;br /&gt;
    return title.length;&lt;br /&gt;
}, 'Title cannot be blank');&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, Mongoose allows us to define methods to our data objects as well. &lt;br /&gt;
These are called statics. From the Mongoose doc: Schemas not only define the structure of your document and casting of properties, they also define document instance methods, static Model methods, compound indexes and document lifecycle hooks called middleware.&lt;br /&gt;
The following code defines a method called load for the article schema:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
ArticleSchema.statics.load = function(id, cb) {&lt;br /&gt;
    this.findOne({&lt;br /&gt;
        _id: id&lt;br /&gt;
    }).populate('user', 'name username').exec(cb);&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have trouble understanding what the code does, review the Mongoose [http://mongoosejs.com/docs/index.html quick start] guide.&lt;br /&gt;
&lt;br /&gt;
=== Models Practice === &lt;br /&gt;
Define a schema for a model named '''Phone''', name it phone.js and save it in the corresponding folder in 'myPackage' (hint: /packages/myPackage/server/models/)&lt;br /&gt;
A product needs to have the following fields with specific types. Here is an example of a Phone object can be stored in the MongoDB:&lt;br /&gt;
&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;age&amp;quot;: 0, &lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;motorola-xoom-with-wi-fi&amp;quot;, &lt;br /&gt;
        &amp;quot;imageUrl&amp;quot;: &amp;quot;img/phones/motorola-xoom-with-wi-fi.0.jpg&amp;quot;, &lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;Motorola XOOM\u2122 with Wi-Fi&amp;quot;, &lt;br /&gt;
        &amp;quot;snippet&amp;quot;: &amp;quot;The Next, Next Generation\r\n\r\nExperience the future with Motorola XOOM with Wi-Fi, the world's first tablet powered by Android 3.0 (Honeycomb).&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
This is taken from phones.json used by the AngularJS tutorial. If you have gone through the tutorial, you should have realized that instead of using a DB, json files were used to simplify the tutorial.&lt;br /&gt;
Find phones.json in /app/phones in the angular tutorial folder and try importing its content to MongoDB so you can use them in your current MEAN package.&lt;br /&gt;
&lt;br /&gt;
*Run '''mongod''' and connect to mongo shell (mongo --shell), then type &amp;quot;use mean-dev&amp;quot; to switch to database used by mean.&lt;br /&gt;
*Type  mongoimport --db mean-dev --collection phones --type json --file ''&amp;lt;path to phones.json&amp;gt;'' --jsonArray&lt;br /&gt;
*Type show collections to see if phones are added to your database, type coll = db.phones to see the content of the file.&lt;br /&gt;
&lt;br /&gt;
== Controllers ==&lt;br /&gt;
&lt;br /&gt;
You'll find a controllers folder on both the server side and the client side.  &lt;br /&gt;
* The client side controllers are part of the Angular MVC scheme that contains client side logic and may issue requests to the server.&lt;br /&gt;
* The server side controllers deal with the models and requests from the client side.&lt;br /&gt;
&lt;br /&gt;
'''Server side:'''&lt;br /&gt;
&lt;br /&gt;
* Find articles.js in the controllers folder. Try to understand what each part does. &lt;br /&gt;
* Find articles.js in /server/routes/middlewares &lt;br /&gt;
You'll see that it requires the articles controller and its methods for querying the database.&lt;br /&gt;
&lt;br /&gt;
The first section requires the articles controller, which defines different methods &lt;br /&gt;
&lt;br /&gt;
For example:     &lt;br /&gt;
app.route('/articles')&lt;br /&gt;
        .get(articles.all)&lt;br /&gt;
tells the server to use a method named &amp;quot;all&amp;quot; in the articles controller when the url is pointed to /articles.&lt;br /&gt;
&lt;br /&gt;
*Go to http://localhost:3000/articles, what do you see? Does it make sense?&lt;br /&gt;
&lt;br /&gt;
'''Client side:''' open up articles.js in /public/articles/controllers&lt;br /&gt;
Compare the functions defined in ArticlesController, can you find the corresponding functions on the server side implementation of articles controller? &lt;br /&gt;
&lt;br /&gt;
Here is a diagram to help you under stand how this works:&lt;br /&gt;
&lt;br /&gt;
[[File:pic]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Views &amp;amp; Routing ==&lt;br /&gt;
Let's switch to the public folder where the views reside. &lt;br /&gt;
&lt;br /&gt;
Go to public/articles/views, open up list.html:&lt;br /&gt;
The first line tells the framework that  ArticlesController is responsible for this particular view and when this view is loaded, use find() to initiate data binding.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;section data-ng-controller=&amp;quot;ArticlesController&amp;quot; data-ng-init=&amp;quot;find()&amp;quot;&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Feel free to take a look at what find() does. Make sure you understand that what find() does is actually done by the backend, where a corresponding find() is written (as mentioned above).&lt;br /&gt;
Hopefully you have a better understanding of how these technologies all work together now.&lt;br /&gt;
&lt;br /&gt;
Review the AngularJS section if you have any questions regarding the view data binding.&lt;br /&gt;
&lt;br /&gt;
The view files in articles/views only defines the code for displaying the articles, where does the navigation bar gets defined.&lt;br /&gt;
The answer is in /public/system. &lt;br /&gt;
*The .html files in public/system/views provide a container/layout for the application. &lt;br /&gt;
For example, header.html includes the menu bar (displayed on the top of the page):&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;left pull-left&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;ul class=&amp;quot;navbar-nav nav&amp;quot;&amp;gt;&lt;br /&gt;
         &amp;lt;li data-ng-repeat=&amp;quot;item in menus.main&amp;quot; ui-route=&amp;quot;/{{item.link}}&amp;quot; ng-class=&amp;quot;{active: $uiRoute}&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;a mean-token=&amp;quot;item.link&amp;quot; ui-sref='{{item.link}}'&amp;gt;{{item.title}}&amp;lt;/a&amp;gt;&lt;br /&gt;
        &amp;lt;/li&amp;gt;&lt;br /&gt;
   &amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Try changing {{item.title}} inside the &amp;lt;a&amp;gt; &amp;lt;/a&amp;gt;tags to &amp;quot;my articles&amp;quot; see what happens to the page.&lt;br /&gt;
* The ui-sref is &amp;quot;href&amp;quot; in ui-route, an AngularJS plugin, try changing {{item.link}} to #!/myarticles, &lt;br /&gt;
* What happens to the application now? When you click on &amp;quot;my articles&amp;quot;?&lt;br /&gt;
&lt;br /&gt;
The page to articles is no longer served!&lt;br /&gt;
&lt;br /&gt;
But how does the framework know which page to serve given a certain url?  The file that's responsible for this (called routing in web development) is in public/articles/routes&lt;br /&gt;
&lt;br /&gt;
open up articles.js found in this folder and find this line:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
            .state('all articles', {&lt;br /&gt;
                url: '/articles',&lt;br /&gt;
                templateUrl: 'public/articles/views/list.html',&lt;br /&gt;
                resolve: {&lt;br /&gt;
                    loggedin: checkLoggedin&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is ui-route's way of telling the server what to serve the page specified by the templateUrl when it sees &amp;quot;localhost:3000/#!/phones&amp;quot;. &lt;br /&gt;
The #! is a hash prefix used for MEAN to make ajax calls so make sure to include it when coding your views.&lt;br /&gt;
Now try changing the url to &amp;quot;/myarticles&amp;quot;, save and go back to your app, click on &amp;quot;my articles&amp;quot; now, what happens?&lt;br /&gt;
&lt;br /&gt;
*This is important if you want to customize your navigation bar and links. Just remember that each url needs an entry in the route file, in the format of the example above.&lt;br /&gt;
&lt;br /&gt;
= Practice = &lt;br /&gt;
&lt;br /&gt;
Can you implement a view in your myPackage to display all phones injected in the DB? &lt;br /&gt;
Hint: myPackage has the same file structure as the default app.&lt;/div&gt;</summary>
		<author><name>Vigo</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=1732</id>
		<title>Getting MEAN</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=1732"/>
		<updated>2014-05-11T23:48:11Z</updated>

		<summary type="html">&lt;p&gt;Vigo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Installation=&lt;br /&gt;
To install MEAN, make sure you already have all of the following components installed and configured correctly.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
'''1. Node.js''' (should come with npm) &amp;lt;br/&amp;gt;&lt;br /&gt;
To find out if you have node and npm, try checking their versions (may not be the same):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
node --version&lt;br /&gt;
v0.10.25&lt;br /&gt;
npm --version&lt;br /&gt;
1.3.24&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
IF you don't have node.js, install it [http://nodejs.org/ here].&lt;br /&gt;
&lt;br /&gt;
'''2. Bower'''&lt;br /&gt;
&lt;br /&gt;
Bower is a web application manager used by MEAN. To install bower, type the following command in your terminal: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;npm i -g bower&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''3. MongoDB'''&lt;br /&gt;
To install MongoDB, follow the instructions for your OS [http://docs.mongodb.org/manual/installation/ here].&lt;br /&gt;
&lt;br /&gt;
'''4. and finally, MEAN'''&lt;br /&gt;
In your terminal, type:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt; &amp;gt; sudo npm install -g meanio@latest &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* MEAN stack documentations are available [http://mean.io/#!/docs here]. They'll help you to get familiar with the file structure and idioms.&lt;br /&gt;
&lt;br /&gt;
=Running the Default App =&lt;br /&gt;
* Init and run an app. &lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; mean init myApp // create your first app&lt;br /&gt;
&amp;gt; cd myApp &lt;br /&gt;
&amp;gt; npm install // Install dependencies&lt;br /&gt;
&amp;gt; grunt // Launch mean&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Make sure MongoDB is connected and running (if you run into problems, refer to the section on MongoDB)&lt;br /&gt;
&lt;br /&gt;
* Go ahead and explore features of the default Article app (such as logging in, adding/deleting articles).&lt;br /&gt;
&lt;br /&gt;
=Generating a Package =&lt;br /&gt;
* By now you should know what a package is in MEAN. If you don't, read [http://mean.io/#!/docs this].&lt;br /&gt;
* Try creating a package named myPackage by typing: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; mean package myPackage;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Locate it inside the packages folder:&lt;br /&gt;
* Compare the structure of myPackage folder to that of the default app. Make sure you see both '''public''' and  '''server''' folders and their subfolders.&lt;br /&gt;
* Restart your app, make sure you can see a link to the newly created package.&lt;br /&gt;
&lt;br /&gt;
=A Closer Look at the App =&lt;br /&gt;
Take a look at the directory where you app resides, you will see two folders '''public''' and  '''server''', which contain code for the client side and server side respectively.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Models ==&lt;br /&gt;
&lt;br /&gt;
Open up article.js in /server/models&lt;br /&gt;
&lt;br /&gt;
MEAN is MVC on the client side and the server side.  Since the model is tied to the backend to MongoDB, you will only see the models folder on the server side, which is normal. &lt;br /&gt;
The models are mongoose models that's why we need to require mongoose (what the following line does):&lt;br /&gt;
&lt;br /&gt;
var mongoose = require('mongoose'), Schema = mongoose.Schema;&lt;br /&gt;
&lt;br /&gt;
The following part then defines the schema:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
var ArticleSchema = new Schema({&lt;br /&gt;
    created: {&lt;br /&gt;
        type: Date,&lt;br /&gt;
        default: Date.now&lt;br /&gt;
    },&lt;br /&gt;
    title: {&lt;br /&gt;
        type: String,&lt;br /&gt;
        default: '',&lt;br /&gt;
        trim: true&lt;br /&gt;
    },&lt;br /&gt;
    content: {&lt;br /&gt;
        type: String,&lt;br /&gt;
        default: '',&lt;br /&gt;
        trim: true&lt;br /&gt;
    },&lt;br /&gt;
    user: {&lt;br /&gt;
        type: Schema.ObjectId,&lt;br /&gt;
        ref: 'User'&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The next part is validations, or criteria an object needs to pass before it can be saved to the DB. &lt;br /&gt;
The following code is to make sure that an article has a title:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
ArticleSchema.path('title').validate(function(title) {&lt;br /&gt;
    return title.length;&lt;br /&gt;
}, 'Title cannot be blank');&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, Mongoose allows us to define methods to our data objects as well. &lt;br /&gt;
These are called statics. From the Mongoose doc: Schemas not only define the structure of your document and casting of properties, they also define document instance methods, static Model methods, compound indexes and document lifecycle hooks called middleware.&lt;br /&gt;
The following code defines a method called load for the article schema:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
ArticleSchema.statics.load = function(id, cb) {&lt;br /&gt;
    this.findOne({&lt;br /&gt;
        _id: id&lt;br /&gt;
    }).populate('user', 'name username').exec(cb);&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have trouble understanding what the code does, review the Mongoose [http://mongoosejs.com/docs/index.html quick start] guide.&lt;br /&gt;
&lt;br /&gt;
=== Models Practice === &lt;br /&gt;
Define a schema for a model named '''Phone''', name it phone.js and save it in the corresponding folder in 'myPackage' (hint: /packages/myPackage/server/models/)&lt;br /&gt;
A product needs to have the following fields with specific types. Here is an example of a Phone object can be stored in the MongoDB:&lt;br /&gt;
&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;age&amp;quot;: 0, &lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;motorola-xoom-with-wi-fi&amp;quot;, &lt;br /&gt;
        &amp;quot;imageUrl&amp;quot;: &amp;quot;img/phones/motorola-xoom-with-wi-fi.0.jpg&amp;quot;, &lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;Motorola XOOM\u2122 with Wi-Fi&amp;quot;, &lt;br /&gt;
        &amp;quot;snippet&amp;quot;: &amp;quot;The Next, Next Generation\r\n\r\nExperience the future with Motorola XOOM with Wi-Fi, the world's first tablet powered by Android 3.0 (Honeycomb).&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
This is taken from phones.json used by the AngularJS tutorial. If you have gone through the tutorial, you should have realized that instead of using a DB, json files were used to simplify the tutorial.&lt;br /&gt;
Find phones.json in /app/phones in the angular tutorial folder and try importing its content to MongoDB so you can use them in your current MEAN package.&lt;br /&gt;
&lt;br /&gt;
*Run '''mongod''' and connect to mongo shell (mongo --shell), then type &amp;quot;use mean-dev&amp;quot; to switch to database used by mean.&lt;br /&gt;
*Type  mongoimport --db mean-dev --collection phones --type json --file ''&amp;lt;path to phones.json&amp;gt;'' --jsonArray&lt;br /&gt;
*Type show collections to see if phones are added to your database, type coll = db.phones to see the content of the file.&lt;br /&gt;
&lt;br /&gt;
== Controllers ==&lt;br /&gt;
&lt;br /&gt;
You'll find a controllers folder on both the server side and the client side.  &lt;br /&gt;
* The client side controllers are part of the Angular MVC scheme that contains client side logic and may issue requests to the server.&lt;br /&gt;
* The server side controllers deal with the models and requests from the client side.&lt;br /&gt;
&lt;br /&gt;
'''Server side:'''&lt;br /&gt;
&lt;br /&gt;
* Find articles.js in the controllers folder. Try to understand what each part does. &lt;br /&gt;
* Find articles.js in /server/routes/middlewares &lt;br /&gt;
You'll see that it requires the articles controller and its methods for querying the database.&lt;br /&gt;
&lt;br /&gt;
The first section requires the articles controller, which defines different methods &lt;br /&gt;
&lt;br /&gt;
For example:     &lt;br /&gt;
app.route('/articles')&lt;br /&gt;
        .get(articles.all)&lt;br /&gt;
tells the server to use a method named &amp;quot;all&amp;quot; in the articles controller when the url is pointed to /articles.&lt;br /&gt;
&lt;br /&gt;
*Go to http://localhost:3000/articles, what do you see? Does it make sense?&lt;br /&gt;
&lt;br /&gt;
'''Client side:''' open up articles.js in /public/articles/controllers&lt;br /&gt;
Compare the functions defined in ArticlesController, can you find the corresponding functions on the server side implementation of articles controller? &lt;br /&gt;
&lt;br /&gt;
Here is a diagram to help you under stand how this works:&lt;br /&gt;
&lt;br /&gt;
[[File:pic]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Views &amp;amp; Routing ==&lt;br /&gt;
Let's switch to the public folder where the views reside. &lt;br /&gt;
&lt;br /&gt;
Go to public/articles/views, open up list.html:&lt;br /&gt;
The first line tells the framework that  ArticlesController is responsible for this particular view and when this view is loaded, use find() to initiate data binding.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;section data-ng-controller=&amp;quot;ArticlesController&amp;quot; data-ng-init=&amp;quot;find()&amp;quot;&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Feel free to take a look at what find() does. Make sure you understand that what find() does is actually done by the backend, where a corresponding find() is written (as mentioned above).&lt;br /&gt;
Hopefully you have a better understanding of how these technologies all work together now.&lt;br /&gt;
&lt;br /&gt;
Review the AngularJS section if you have any questions regarding the view data binding.&lt;br /&gt;
&lt;br /&gt;
The view files in articles/views only defines the code for displaying the articles, where does the navigation bar gets defined.&lt;br /&gt;
The answer is in /public/system. &lt;br /&gt;
*The .html files in public/system/views provide a container/layout for the application. &lt;br /&gt;
For example, header.html includes the menu bar (displayed on the top of the page):&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;source lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;left pull-left&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;ul class=&amp;quot;navbar-nav nav&amp;quot;&amp;gt;&lt;br /&gt;
         &amp;lt;li data-ng-repeat=&amp;quot;item in menus.main&amp;quot; ui-route=&amp;quot;/{{item.link}}&amp;quot; ng-class=&amp;quot;{active: $uiRoute}&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;a mean-token=&amp;quot;item.link&amp;quot; ui-sref='{{item.link}}'&amp;gt;{{item.title}}&amp;lt;/a&amp;gt;&lt;br /&gt;
        &amp;lt;/li&amp;gt;&lt;br /&gt;
   &amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Try changing {{item.title}} inside the &amp;lt;a&amp;gt; &amp;lt;/a&amp;gt;tags to &amp;quot;my articles&amp;quot; see what happens to the page.&lt;br /&gt;
* The ui-sref is &amp;quot;href&amp;quot; in ui-route, an AngularJS plugin, try changing {{item.link}} to #!/myarticles, &lt;br /&gt;
* What happens to the application now? When you click on &amp;quot;my articles&amp;quot;?&lt;br /&gt;
&lt;br /&gt;
The page to articles is no longer served!&lt;br /&gt;
&lt;br /&gt;
But how does the framework know which page to serve given a certain url?  The file that's responsible for this (called routing in web development) is in public/articles/routes&lt;br /&gt;
&lt;br /&gt;
open up articles.js found in this folder and find this line:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
            .state('all articles', {&lt;br /&gt;
                url: '/articles',&lt;br /&gt;
                templateUrl: 'public/articles/views/list.html',&lt;br /&gt;
                resolve: {&lt;br /&gt;
                    loggedin: checkLoggedin&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is ui-route's way of telling the server what to serve the page specified by the templateUrl when it sees &amp;quot;localhost:3000/#!/phones&amp;quot;. &lt;br /&gt;
The #! is a hash prefix used for MEAN to make ajax calls so make sure to include it when coding your views.&lt;br /&gt;
Now try changing the url to &amp;quot;/myarticles&amp;quot;, save and go back to your app, click on &amp;quot;my articles&amp;quot; now, what happens?&lt;br /&gt;
&lt;br /&gt;
*This is important if you want to customize your navigation bar and links. Just remember that each url needs an entry in the route file, in the format of the example above.&lt;br /&gt;
&lt;br /&gt;
= Practice = &lt;br /&gt;
&lt;br /&gt;
Can you implement a view in your myPackage to display all phones injected in the DB? &lt;br /&gt;
Hint: myPackage has the same file structure as the default app.&lt;/div&gt;</summary>
		<author><name>Vigo</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=1731</id>
		<title>Getting MEAN</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=1731"/>
		<updated>2014-05-11T23:45:27Z</updated>

		<summary type="html">&lt;p&gt;Vigo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Installation=&lt;br /&gt;
To install MEAN, make sure you already have all of the following components installed and configured correctly.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
'''1. Node.js''' (should come with npm) &amp;lt;br/&amp;gt;&lt;br /&gt;
To find out if you have node and npm, try checking their versions (may not be the same):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
node --version&lt;br /&gt;
v0.10.25&lt;br /&gt;
npm --version&lt;br /&gt;
1.3.24&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
IF you don't have node.js, install it [http://nodejs.org/ here].&lt;br /&gt;
&lt;br /&gt;
'''2. Bower'''&lt;br /&gt;
&lt;br /&gt;
Bower is a web application manager used by MEAN. To install bower, type the following command in your terminal: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;npm i -g bower&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''3. MongoDB'''&lt;br /&gt;
To install MongoDB, follow the instructions for your OS [http://docs.mongodb.org/manual/installation/ here].&lt;br /&gt;
&lt;br /&gt;
'''4. and finally, MEAN'''&lt;br /&gt;
In your terminal, type:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt; &amp;gt; sudo npm install -g meanio@latest &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* MEAN stack documentations are available [http://mean.io/#!/docs here]. They'll help you to get familiar with the file structure and idioms.&lt;br /&gt;
&lt;br /&gt;
=Running the Default App =&lt;br /&gt;
* Init and run an app. &lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; mean init myApp // create your first app&lt;br /&gt;
&amp;gt; cd myApp &lt;br /&gt;
&amp;gt; npm install // Install dependencies&lt;br /&gt;
&amp;gt; grunt // Launch mean&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Make sure MongoDB is connected and running (if you run into problems, refer to the section on MongoDB)&lt;br /&gt;
&lt;br /&gt;
* Go ahead and explore features of the default Article app (such as logging in, adding/deleting articles).&lt;br /&gt;
&lt;br /&gt;
=Generating a Package =&lt;br /&gt;
* By now you should know what a package is in MEAN. If you don't, read [http://mean.io/#!/docs this].&lt;br /&gt;
* Try creating a package named myPackage by typing: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; mean package myPackage;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Locate it inside the packages folder:&lt;br /&gt;
* Compare the structure of myPackage folder to that of the default app. Make sure you see both '''public''' and  '''server''' folders and their subfolders.&lt;br /&gt;
* Restart your app, make sure you can see a link to the newly created package.&lt;br /&gt;
&lt;br /&gt;
=A Closer Look at the App =&lt;br /&gt;
Take a look at the directory where you app resides, you will see two folders '''public''' and  '''server''', which contain code for the client side and server side respectively.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Models ==&lt;br /&gt;
&lt;br /&gt;
Open up article.js in /server/models&lt;br /&gt;
&lt;br /&gt;
MEAN is MVC on the client side and the server side.  Since the model is tied to the backend to MongoDB, you will only see the models folder on the server side, which is normal. &lt;br /&gt;
The models are mongoose models that's why we need to require mongoose (what the following line does):&lt;br /&gt;
&lt;br /&gt;
var mongoose = require('mongoose'), Schema = mongoose.Schema;&lt;br /&gt;
&lt;br /&gt;
The following part then defines the schema:&lt;br /&gt;
&lt;br /&gt;
var ArticleSchema = new Schema({&lt;br /&gt;
    created: {&lt;br /&gt;
        type: Date,&lt;br /&gt;
        default: Date.now&lt;br /&gt;
    },&lt;br /&gt;
    title: {&lt;br /&gt;
        type: String,&lt;br /&gt;
        default: '',&lt;br /&gt;
        trim: true&lt;br /&gt;
    },&lt;br /&gt;
    content: {&lt;br /&gt;
        type: String,&lt;br /&gt;
        default: '',&lt;br /&gt;
        trim: true&lt;br /&gt;
    },&lt;br /&gt;
    user: {&lt;br /&gt;
        type: Schema.ObjectId,&lt;br /&gt;
        ref: 'User'&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
The next part is validations, or criteria an object needs to pass before it can be saved to the DB. &lt;br /&gt;
The following code is to make sure that an article has a title:&lt;br /&gt;
&lt;br /&gt;
ArticleSchema.path('title').validate(function(title) {&lt;br /&gt;
    return title.length;&lt;br /&gt;
}, 'Title cannot be blank');&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Finally, Mongoose allows us to define methods to our data objects as well. &lt;br /&gt;
These are called statics. From the Mongoose doc: Schemas not only define the structure of your document and casting of properties, they also define document instance methods, static Model methods, compound indexes and document lifecycle hooks called middleware.&lt;br /&gt;
The following code defines a method called load for the article schema:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
ArticleSchema.statics.load = function(id, cb) {&lt;br /&gt;
    this.findOne({&lt;br /&gt;
        _id: id&lt;br /&gt;
    }).populate('user', 'name username').exec(cb);&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have trouble understanding what the code does, review the Mongoose [http://mongoosejs.com/docs/index.html quick start] guide.&lt;br /&gt;
&lt;br /&gt;
= Models Practice = &lt;br /&gt;
Define a schema for a model named '''Phone''', name it phone.js and save it in the corresponding folder in 'myPackage' (hint: /packages/myPackage/server/models/)&lt;br /&gt;
A product needs to have the following fields with specific types. Here is an example of a Phone object can be stored in the MongoDB:&lt;br /&gt;
&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;age&amp;quot;: 0, &lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;motorola-xoom-with-wi-fi&amp;quot;, &lt;br /&gt;
        &amp;quot;imageUrl&amp;quot;: &amp;quot;img/phones/motorola-xoom-with-wi-fi.0.jpg&amp;quot;, &lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;Motorola XOOM\u2122 with Wi-Fi&amp;quot;, &lt;br /&gt;
        &amp;quot;snippet&amp;quot;: &amp;quot;The Next, Next Generation\r\n\r\nExperience the future with Motorola XOOM with Wi-Fi, the world's first tablet powered by Android 3.0 (Honeycomb).&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
This is taken from phones.json used by the AngularJS tutorial. If you have gone through the tutorial, you should have realized that instead of using a DB, json files were used to simplify the tutorial.&lt;br /&gt;
Find phones.json in /app/phones in the angular tutorial folder and try importing its content to MongoDB so you can use them in your current MEAN package.&lt;br /&gt;
&lt;br /&gt;
*Run '''mongod''' and connect to mongo shell (mongo --shell), then type &amp;quot;use mean-dev&amp;quot; to switch to database used by mean.&lt;br /&gt;
*Type  mongoimport --db mean-dev --collection phones --type json --file ''&amp;lt;path to phones.json&amp;gt;'' --jsonArray&lt;br /&gt;
*Type show collections to see if phones are added to your database, type coll = db.phones to see the content of the file.&lt;br /&gt;
&lt;br /&gt;
= Controllers =&lt;br /&gt;
&lt;br /&gt;
You'll find a controllers folder on both the server side and the client side.  &lt;br /&gt;
* The client side controllers are part of the Angular MVC scheme that contains client side logic and may issue requests to the server.&lt;br /&gt;
* The server side controllers deal with the models and requests from the client side.&lt;br /&gt;
&lt;br /&gt;
'''Server side:'''&lt;br /&gt;
&lt;br /&gt;
* Find articles.js in the controllers folder. Try to understand what each part does. &lt;br /&gt;
* Find articles.js in /server/routes/middlewares &lt;br /&gt;
You'll see that it requires the articles controller and its methods for querying the database.&lt;br /&gt;
&lt;br /&gt;
The first section requires the articles controller, which defines different methods &lt;br /&gt;
&lt;br /&gt;
For example:     &lt;br /&gt;
app.route('/articles')&lt;br /&gt;
        .get(articles.all)&lt;br /&gt;
tells the server to use a method named &amp;quot;all&amp;quot; in the articles controller when the url is pointed to /articles.&lt;br /&gt;
&lt;br /&gt;
*Go to http://localhost:3000/articles, what do you see? Does it make sense?&lt;br /&gt;
&lt;br /&gt;
'''Client side:''' open up articles.js in /public/articles/controllers&lt;br /&gt;
Compare the functions defined in ArticlesController, can you find the corresponding functions on the server side implementation of articles controller? &lt;br /&gt;
&lt;br /&gt;
Here is a diagram to help you under stand how this works:&lt;br /&gt;
&lt;br /&gt;
[[File:pic]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Views &amp;amp; Routing ==&lt;br /&gt;
Let's switch to the public folder where the views reside. &lt;br /&gt;
&lt;br /&gt;
Go to public/articles/views, open up list.html:&lt;br /&gt;
The first line tells the framework that  ArticlesController is responsible for this particular view and when this view is loaded, use find() to initiate data binding.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;section data-ng-controller=&amp;quot;ArticlesController&amp;quot; data-ng-init=&amp;quot;find()&amp;quot;&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Feel free to take a look at what find() does. Make sure you understand that what find() does is actually done by the backend, where a corresponding find() is written (as mentioned above).&lt;br /&gt;
Hopefully you have a better understanding of how these technologies all work together now.&lt;br /&gt;
&lt;br /&gt;
Review the AngularJS section if you have any questions regarding the view data binding.&lt;br /&gt;
&lt;br /&gt;
The view files in articles/views only defines the code for displaying the articles, where does the navigation bar gets defined.&lt;br /&gt;
The answer is in /public/system. &lt;br /&gt;
*The .html files in public/system/views provide a container/layout for the application. &lt;br /&gt;
For example, header.html includes the menu bar (displayed on the top of the page):&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;source lang=&amp;quot;html&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;left pull-left&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;ul class=&amp;quot;navbar-nav nav&amp;quot;&amp;gt;&lt;br /&gt;
         &amp;lt;li data-ng-repeat=&amp;quot;item in menus.main&amp;quot; ui-route=&amp;quot;/{{item.link}}&amp;quot; ng-class=&amp;quot;{active: $uiRoute}&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;a mean-token=&amp;quot;item.link&amp;quot; ui-sref='{{item.link}}'&amp;gt;{{item.title}}&amp;lt;/a&amp;gt;&lt;br /&gt;
        &amp;lt;/li&amp;gt;&lt;br /&gt;
   &amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Try changing {{item.title}} inside the &amp;lt;a&amp;gt; &amp;lt;/a&amp;gt;tags to &amp;quot;my articles&amp;quot; see what happens to the page.&lt;br /&gt;
* The ui-sref is &amp;quot;href&amp;quot; in ui-route, an AngularJS plugin, try changing {{item.link}} to #!/myarticles, &lt;br /&gt;
* What happens to the application now? When you click on &amp;quot;my articles&amp;quot;?&lt;br /&gt;
&lt;br /&gt;
The page to articles is no longer served!&lt;br /&gt;
&lt;br /&gt;
But how does the framework know which page to serve given a certain url?  The file that's responsible for this (called routing in web development) is in public/articles/routes&lt;br /&gt;
&lt;br /&gt;
open up articles.js found in this folder and find this line:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
            .state('all articles', {&lt;br /&gt;
                url: '/articles',&lt;br /&gt;
                templateUrl: 'public/articles/views/list.html',&lt;br /&gt;
                resolve: {&lt;br /&gt;
                    loggedin: checkLoggedin&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is ui-route's way of telling the server what to serve the page specified by the templateUrl when it sees &amp;quot;localhost:3000/#!/phones&amp;quot;. &lt;br /&gt;
The #! is a hash prefix used for MEAN to make ajax calls so make sure to include it when coding your views.&lt;br /&gt;
Now try changing the url to &amp;quot;/myarticles&amp;quot;, save and go back to your app, click on &amp;quot;my articles&amp;quot; now, what happens?&lt;br /&gt;
&lt;br /&gt;
*This is important if you want to customize your navigation bar and links. Just remember that each url needs an entry in the route file, in the format of the example above.&lt;br /&gt;
&lt;br /&gt;
= Practice = &lt;br /&gt;
&lt;br /&gt;
Can you implement a view in your myPackage to display all phones injected in the DB? &lt;br /&gt;
Hint: myPackage has the same file structure as the default app.&lt;/div&gt;</summary>
		<author><name>Vigo</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=1730</id>
		<title>Getting MEAN</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=1730"/>
		<updated>2014-05-11T23:40:31Z</updated>

		<summary type="html">&lt;p&gt;Vigo: /* Installation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Installation ===&lt;br /&gt;
To install MEAN, make sure you already have all of the following components installed and configured correctly.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
'''1. Node.js''' (should come with npm) &amp;lt;br/&amp;gt;&lt;br /&gt;
To find out if you have node and npm, try checking their versions (may not be the same):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
node --version&lt;br /&gt;
v0.10.25&lt;br /&gt;
npm --version&lt;br /&gt;
1.3.24&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
IF you don't have node.js, install it [http://nodejs.org/ here].&lt;br /&gt;
&lt;br /&gt;
'''2. Bower'''&lt;br /&gt;
&lt;br /&gt;
Bower is a web application manager used by MEAN. To install bower, type the following command in your terminal: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;npm i -g bower&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''3. MongoDB'''&lt;br /&gt;
To install MongoDB, follow the instructions for your OS [http://docs.mongodb.org/manual/installation/ here].&lt;br /&gt;
&lt;br /&gt;
'''4. and finally, MEAN'''&lt;br /&gt;
In your terminal, type:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt; &amp;gt; sudo npm install -g meanio@latest &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* MEAN stack documentations are available [http://mean.io/#!/docs here]. They'll help you to get familiar with the file structure and idioms.&lt;br /&gt;
&lt;br /&gt;
=== Running the Default App ===&lt;br /&gt;
* Init and run an app. &lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; mean init myApp // create your first app&lt;br /&gt;
&amp;gt; cd myApp &lt;br /&gt;
&amp;gt; npm install // Install dependencies&lt;br /&gt;
&amp;gt; grunt // Launch mean&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Make sure MongoDB is connected and running (if you run into problems, refer to the section on MongoDB)&lt;br /&gt;
&lt;br /&gt;
* Go ahead and explore features of the default Article app (such as logging in, adding/deleting articles).&lt;br /&gt;
&lt;br /&gt;
=== Generating a Package === &lt;br /&gt;
* By now you should know what a package is in MEAN. If you don't, read [http://mean.io/#!/docs this].&lt;br /&gt;
* Try creating a package named myPackage by typing: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; mean package myPackage;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Locate it inside the packages folder:&lt;br /&gt;
* Compare the structure of myPackage folder to that of the default app. Make sure you see both '''public''' and  '''server''' folders and their subfolders.&lt;br /&gt;
* Restart your app, make sure you can see a link to the newly created package.&lt;br /&gt;
&lt;br /&gt;
=== A Closer Look at the App ===&lt;br /&gt;
Take a look at the directory where you app resides, you will see two folders '''public''' and  '''server''', which contain code for the client side and server side respectively.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Models =&lt;br /&gt;
&lt;br /&gt;
Open up article.js in /server/models&lt;br /&gt;
&lt;br /&gt;
MEAN is MVC on the client side and the server side.  Since the model is tied to the backend to MongoDB, you will only see the models folder on the server side, which is normal. &lt;br /&gt;
The models are mongoose models that's why we need to require mongoose (what the following line does):&lt;br /&gt;
&lt;br /&gt;
var mongoose = require('mongoose'), Schema = mongoose.Schema;&lt;br /&gt;
&lt;br /&gt;
The following part then defines the schema:&lt;br /&gt;
&lt;br /&gt;
var ArticleSchema = new Schema({&lt;br /&gt;
    created: {&lt;br /&gt;
        type: Date,&lt;br /&gt;
        default: Date.now&lt;br /&gt;
    },&lt;br /&gt;
    title: {&lt;br /&gt;
        type: String,&lt;br /&gt;
        default: '',&lt;br /&gt;
        trim: true&lt;br /&gt;
    },&lt;br /&gt;
    content: {&lt;br /&gt;
        type: String,&lt;br /&gt;
        default: '',&lt;br /&gt;
        trim: true&lt;br /&gt;
    },&lt;br /&gt;
    user: {&lt;br /&gt;
        type: Schema.ObjectId,&lt;br /&gt;
        ref: 'User'&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
The next part is validations, or criteria an object needs to pass before it can be saved to the DB. &lt;br /&gt;
The following code is to make sure that an article has a title:&lt;br /&gt;
&lt;br /&gt;
ArticleSchema.path('title').validate(function(title) {&lt;br /&gt;
    return title.length;&lt;br /&gt;
}, 'Title cannot be blank');&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Finally, Mongoose allows us to define methods to our data objects as well. &lt;br /&gt;
These are called statics. From the Mongoose doc: Schemas not only define the structure of your document and casting of properties, they also define document instance methods, static Model methods, compound indexes and document lifecycle hooks called middleware.&lt;br /&gt;
The following code defines a method called load for the article schema:&lt;br /&gt;
&lt;br /&gt;
ArticleSchema.statics.load = function(id, cb) {&lt;br /&gt;
    this.findOne({&lt;br /&gt;
        _id: id&lt;br /&gt;
    }).populate('user', 'name username').exec(cb);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
If you have trouble understanding what the code does, review the Mongoose [http://mongoosejs.com/docs/index.html quick start] guide.&lt;br /&gt;
&lt;br /&gt;
= Models Practice = &lt;br /&gt;
Define a schema for a model named '''Phone''', name it phone.js and save it in the corresponding folder in 'myPackage' (hint: /packages/myPackage/server/models/)&lt;br /&gt;
A product needs to have the following fields with specific types. Here is an example of a Phone object can be stored in the MongoDB:&lt;br /&gt;
&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;age&amp;quot;: 0, &lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;motorola-xoom-with-wi-fi&amp;quot;, &lt;br /&gt;
        &amp;quot;imageUrl&amp;quot;: &amp;quot;img/phones/motorola-xoom-with-wi-fi.0.jpg&amp;quot;, &lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;Motorola XOOM\u2122 with Wi-Fi&amp;quot;, &lt;br /&gt;
        &amp;quot;snippet&amp;quot;: &amp;quot;The Next, Next Generation\r\n\r\nExperience the future with Motorola XOOM with Wi-Fi, the world's first tablet powered by Android 3.0 (Honeycomb).&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
This is taken from phones.json used by the AngularJS tutorial. If you have gone through the tutorial, you should have realized that instead of using a DB, json files were used to simplify the tutorial.&lt;br /&gt;
Find phones.json in /app/phones in the angular tutorial folder and try importing its content to MongoDB so you can use them in your current MEAN package.&lt;br /&gt;
&lt;br /&gt;
*Run '''mongod''' and connect to mongo shell (mongo --shell), then type &amp;quot;use mean-dev&amp;quot; to switch to database used by mean.&lt;br /&gt;
*Type  mongoimport --db mean-dev --collection phones --type json --file ''&amp;lt;path to phones.json&amp;gt;'' --jsonArray&lt;br /&gt;
*Type show collections to see if phones are added to your database, type coll = db.phones to see the content of the file.&lt;br /&gt;
&lt;br /&gt;
= Controllers =&lt;br /&gt;
&lt;br /&gt;
You'll find a controllers folder on both the server side and the client side.  &lt;br /&gt;
* The client side controllers are part of the Angular MVC scheme that contains client side logic and may issue requests to the server.&lt;br /&gt;
* The server side controllers deal with the models and requests from the client side.&lt;br /&gt;
&lt;br /&gt;
'''Server side:'''&lt;br /&gt;
&lt;br /&gt;
* Find articles.js in the controllers folder. Try to understand what each part does. &lt;br /&gt;
* Find articles.js in /server/routes/middlewares &lt;br /&gt;
You'll see that it requires the articles controller and its methods for querying the database.&lt;br /&gt;
&lt;br /&gt;
The first section requires the articles controller, which defines different methods &lt;br /&gt;
&lt;br /&gt;
For example:     &lt;br /&gt;
app.route('/articles')&lt;br /&gt;
        .get(articles.all)&lt;br /&gt;
tells the server to use a method named &amp;quot;all&amp;quot; in the articles controller when the url is pointed to /articles.&lt;br /&gt;
&lt;br /&gt;
*Go to http://localhost:3000/articles, what do you see? Does it make sense?&lt;br /&gt;
&lt;br /&gt;
'''Client side:''' open up articles.js in /public/articles/controllers&lt;br /&gt;
Compare the functions defined in ArticlesController, can you find the corresponding functions on the server side implementation of articles controller? &lt;br /&gt;
&lt;br /&gt;
Here is a diagram to help you under stand how this works:&lt;br /&gt;
&lt;br /&gt;
[[File:pic]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Views &amp;amp; Routing =&lt;br /&gt;
Let's switch to the public folder where the views reside. &lt;br /&gt;
&lt;br /&gt;
Go to public/articles/views, open up list.html:&lt;br /&gt;
The first line tells the framework that  ArticlesController is responsible for this particular view and when this view is loaded, use find() to initiate data binding.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;section data-ng-controller=&amp;quot;ArticlesController&amp;quot; data-ng-init=&amp;quot;find()&amp;quot;&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Feel free to take a look at what find() does. Make sure you understand that what find() does is actually done by the backend, where a corresponding find() is written (as mentioned above).&lt;br /&gt;
Hopefully you have a better understanding of how these technologies all work together now.&lt;br /&gt;
&lt;br /&gt;
Review the AngularJS section if you have any questions regarding the view data binding.&lt;br /&gt;
&lt;br /&gt;
The view files in articles/views only defines the code for displaying the articles, where does the navigation bar gets defined.&lt;br /&gt;
The answer is in /public/system. &lt;br /&gt;
*The .html files in public/system/views provide a container/layout for the application. &lt;br /&gt;
For example, header.html includes the menu bar (displayed on the top of the page):&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
*&amp;lt;nowiki&amp;gt; &amp;lt;div class=&amp;quot;left pull-left&amp;quot;&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*    &amp;lt;nowiki&amp;gt;    &amp;lt;ul class=&amp;quot;navbar-nav nav&amp;quot;&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*        &amp;lt;nowiki&amp;gt;      &amp;lt;li data-ng-repeat=&amp;quot;item in menus.main&amp;quot; ui-route=&amp;quot;/{{item.link}}&amp;quot; ng-class=&amp;quot;{active: $uiRoute}&amp;quot;&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*            &amp;lt;nowiki&amp;gt;         &amp;lt;a mean-token=&amp;quot;item.link&amp;quot; ui-sref='{{item.link}}'&amp;gt;{{item.title}}&amp;lt;/a&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*        &amp;lt;nowiki&amp;gt;     &amp;lt;/li&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*    &amp;lt;nowiki&amp;gt;   &amp;lt;/ul&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*&amp;lt;nowiki&amp;gt; &amp;lt;/div&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Try changing {{item.title}} inside the &amp;lt;a&amp;gt; &amp;lt;/a&amp;gt;tags to &amp;quot;my articles&amp;quot; see what happens to the page.&lt;br /&gt;
* The ui-sref is &amp;quot;href&amp;quot; in ui-route, an AngularJS plugin, try changing {{item.link}} to #!/myarticles, &lt;br /&gt;
* What happens to the application now? When you click on &amp;quot;my articles&amp;quot;?&lt;br /&gt;
&lt;br /&gt;
The page to articles is no longer served!&lt;br /&gt;
&lt;br /&gt;
But how does the framework know which page to serve given a certain url?  The file that's responsible for this (called routing in web development) is in public/articles/routes&lt;br /&gt;
&lt;br /&gt;
open up articles.js found in this folder and find this line:&lt;br /&gt;
&lt;br /&gt;
            .state('all articles', {&lt;br /&gt;
                url: '/articles',&lt;br /&gt;
                templateUrl: 'public/articles/views/list.html',&lt;br /&gt;
                resolve: {&lt;br /&gt;
                    loggedin: checkLoggedin&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
This is ui-route's way of telling the server what to serve the page specified by the templateUrl when it sees &amp;quot;localhost:3000/#!/phones&amp;quot;. &lt;br /&gt;
The #! is a hash prefix used for MEAN to make ajax calls so make sure to include it when coding your views.&lt;br /&gt;
Now try changing the url to &amp;quot;/myarticles&amp;quot;, save and go back to your app, click on &amp;quot;my articles&amp;quot; now, what happens?&lt;br /&gt;
&lt;br /&gt;
*This is important if you want to customize your navigation bar and links. Just remember that each url needs an entry in the route file, in the format of the example above.&lt;br /&gt;
&lt;br /&gt;
= Practice = &lt;br /&gt;
&lt;br /&gt;
Can you implement a view in your myPackage to display all phones injected in the DB? &lt;br /&gt;
Hint: myPackage has the same file structure as the default app.&lt;/div&gt;</summary>
		<author><name>Vigo</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=1729</id>
		<title>Getting MEAN</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=1729"/>
		<updated>2014-05-11T23:37:54Z</updated>

		<summary type="html">&lt;p&gt;Vigo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Installation ===&lt;br /&gt;
To install MEAN, make sure you already have all of the following components installed and configured correctly.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
'''1. Node.js''' (should come with npm) &amp;lt;br/&amp;gt;&lt;br /&gt;
To find out if you have node and npm, try checking their versions (may not be the same):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
node --version&lt;br /&gt;
v0.10.25&lt;br /&gt;
npm --version&lt;br /&gt;
1.3.24&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
IF you don't have node.js, install it [http://nodejs.org/ here].&lt;br /&gt;
&lt;br /&gt;
'''2. Bower'''&lt;br /&gt;
&lt;br /&gt;
Bower is a web application manager used by MEAN. To install bower, type the following command in your terminal: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;npm i -g bower&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''3. MongoDB'''&lt;br /&gt;
To install MongoDB, follow the instructions for your OS [http://docs.mongodb.org/manual/installation/ here].&lt;br /&gt;
&lt;br /&gt;
'''4. and finally, MEAN'''&lt;br /&gt;
In your terminal, type:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt; &amp;gt; sudo npm install -g meanio@latest &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Take a moment and read the rest of the [http://mean.io/#!/docs docs] to get familiar with the file structure and idioms.&lt;br /&gt;
&lt;br /&gt;
=== Running the Default App ===&lt;br /&gt;
* Init and run an app. &lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; mean init myApp // create your first app&lt;br /&gt;
&amp;gt; cd myApp &lt;br /&gt;
&amp;gt; npm install // Install dependencies&lt;br /&gt;
&amp;gt; grunt // Launch mean&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Make sure MongoDB is connected and running (if you run into problems, refer to the section on MongoDB)&lt;br /&gt;
&lt;br /&gt;
* Go ahead and explore features of the default Article app (such as logging in, adding/deleting articles).&lt;br /&gt;
&lt;br /&gt;
=== Generating a Package === &lt;br /&gt;
* By now you should know what a package is in MEAN. If you don't, read [http://mean.io/#!/docs this].&lt;br /&gt;
* Try creating a package named myPackage by typing: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; mean package myPackage;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Locate it inside the packages folder:&lt;br /&gt;
* Compare the structure of myPackage folder to that of the default app. Make sure you see both '''public''' and  '''server''' folders and their subfolders.&lt;br /&gt;
* Restart your app, make sure you can see a link to the newly created package.&lt;br /&gt;
&lt;br /&gt;
=== A Closer Look at the App ===&lt;br /&gt;
Take a look at the directory where you app resides, you will see two folders '''public''' and  '''server''', which contain code for the client side and server side respectively.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Models =&lt;br /&gt;
&lt;br /&gt;
Open up article.js in /server/models&lt;br /&gt;
&lt;br /&gt;
MEAN is MVC on the client side and the server side.  Since the model is tied to the backend to MongoDB, you will only see the models folder on the server side, which is normal. &lt;br /&gt;
The models are mongoose models that's why we need to require mongoose (what the following line does):&lt;br /&gt;
&lt;br /&gt;
var mongoose = require('mongoose'), Schema = mongoose.Schema;&lt;br /&gt;
&lt;br /&gt;
The following part then defines the schema:&lt;br /&gt;
&lt;br /&gt;
var ArticleSchema = new Schema({&lt;br /&gt;
    created: {&lt;br /&gt;
        type: Date,&lt;br /&gt;
        default: Date.now&lt;br /&gt;
    },&lt;br /&gt;
    title: {&lt;br /&gt;
        type: String,&lt;br /&gt;
        default: '',&lt;br /&gt;
        trim: true&lt;br /&gt;
    },&lt;br /&gt;
    content: {&lt;br /&gt;
        type: String,&lt;br /&gt;
        default: '',&lt;br /&gt;
        trim: true&lt;br /&gt;
    },&lt;br /&gt;
    user: {&lt;br /&gt;
        type: Schema.ObjectId,&lt;br /&gt;
        ref: 'User'&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
The next part is validations, or criteria an object needs to pass before it can be saved to the DB. &lt;br /&gt;
The following code is to make sure that an article has a title:&lt;br /&gt;
&lt;br /&gt;
ArticleSchema.path('title').validate(function(title) {&lt;br /&gt;
    return title.length;&lt;br /&gt;
}, 'Title cannot be blank');&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Finally, Mongoose allows us to define methods to our data objects as well. &lt;br /&gt;
These are called statics. From the Mongoose doc: Schemas not only define the structure of your document and casting of properties, they also define document instance methods, static Model methods, compound indexes and document lifecycle hooks called middleware.&lt;br /&gt;
The following code defines a method called load for the article schema:&lt;br /&gt;
&lt;br /&gt;
ArticleSchema.statics.load = function(id, cb) {&lt;br /&gt;
    this.findOne({&lt;br /&gt;
        _id: id&lt;br /&gt;
    }).populate('user', 'name username').exec(cb);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
If you have trouble understanding what the code does, review the Mongoose [http://mongoosejs.com/docs/index.html quick start] guide.&lt;br /&gt;
&lt;br /&gt;
= Models Practice = &lt;br /&gt;
Define a schema for a model named '''Phone''', name it phone.js and save it in the corresponding folder in 'myPackage' (hint: /packages/myPackage/server/models/)&lt;br /&gt;
A product needs to have the following fields with specific types. Here is an example of a Phone object can be stored in the MongoDB:&lt;br /&gt;
&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;age&amp;quot;: 0, &lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;motorola-xoom-with-wi-fi&amp;quot;, &lt;br /&gt;
        &amp;quot;imageUrl&amp;quot;: &amp;quot;img/phones/motorola-xoom-with-wi-fi.0.jpg&amp;quot;, &lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;Motorola XOOM\u2122 with Wi-Fi&amp;quot;, &lt;br /&gt;
        &amp;quot;snippet&amp;quot;: &amp;quot;The Next, Next Generation\r\n\r\nExperience the future with Motorola XOOM with Wi-Fi, the world's first tablet powered by Android 3.0 (Honeycomb).&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
This is taken from phones.json used by the AngularJS tutorial. If you have gone through the tutorial, you should have realized that instead of using a DB, json files were used to simplify the tutorial.&lt;br /&gt;
Find phones.json in /app/phones in the angular tutorial folder and try importing its content to MongoDB so you can use them in your current MEAN package.&lt;br /&gt;
&lt;br /&gt;
*Run '''mongod''' and connect to mongo shell (mongo --shell), then type &amp;quot;use mean-dev&amp;quot; to switch to database used by mean.&lt;br /&gt;
*Type  mongoimport --db mean-dev --collection phones --type json --file ''&amp;lt;path to phones.json&amp;gt;'' --jsonArray&lt;br /&gt;
*Type show collections to see if phones are added to your database, type coll = db.phones to see the content of the file.&lt;br /&gt;
&lt;br /&gt;
= Controllers =&lt;br /&gt;
&lt;br /&gt;
You'll find a controllers folder on both the server side and the client side.  &lt;br /&gt;
* The client side controllers are part of the Angular MVC scheme that contains client side logic and may issue requests to the server.&lt;br /&gt;
* The server side controllers deal with the models and requests from the client side.&lt;br /&gt;
&lt;br /&gt;
'''Server side:'''&lt;br /&gt;
&lt;br /&gt;
* Find articles.js in the controllers folder. Try to understand what each part does. &lt;br /&gt;
* Find articles.js in /server/routes/middlewares &lt;br /&gt;
You'll see that it requires the articles controller and its methods for querying the database.&lt;br /&gt;
&lt;br /&gt;
The first section requires the articles controller, which defines different methods &lt;br /&gt;
&lt;br /&gt;
For example:     &lt;br /&gt;
app.route('/articles')&lt;br /&gt;
        .get(articles.all)&lt;br /&gt;
tells the server to use a method named &amp;quot;all&amp;quot; in the articles controller when the url is pointed to /articles.&lt;br /&gt;
&lt;br /&gt;
*Go to http://localhost:3000/articles, what do you see? Does it make sense?&lt;br /&gt;
&lt;br /&gt;
'''Client side:''' open up articles.js in /public/articles/controllers&lt;br /&gt;
Compare the functions defined in ArticlesController, can you find the corresponding functions on the server side implementation of articles controller? &lt;br /&gt;
&lt;br /&gt;
Here is a diagram to help you under stand how this works:&lt;br /&gt;
&lt;br /&gt;
[[File:pic]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Views &amp;amp; Routing =&lt;br /&gt;
Let's switch to the public folder where the views reside. &lt;br /&gt;
&lt;br /&gt;
Go to public/articles/views, open up list.html:&lt;br /&gt;
The first line tells the framework that  ArticlesController is responsible for this particular view and when this view is loaded, use find() to initiate data binding.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;section data-ng-controller=&amp;quot;ArticlesController&amp;quot; data-ng-init=&amp;quot;find()&amp;quot;&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Feel free to take a look at what find() does. Make sure you understand that what find() does is actually done by the backend, where a corresponding find() is written (as mentioned above).&lt;br /&gt;
Hopefully you have a better understanding of how these technologies all work together now.&lt;br /&gt;
&lt;br /&gt;
Review the AngularJS section if you have any questions regarding the view data binding.&lt;br /&gt;
&lt;br /&gt;
The view files in articles/views only defines the code for displaying the articles, where does the navigation bar gets defined.&lt;br /&gt;
The answer is in /public/system. &lt;br /&gt;
*The .html files in public/system/views provide a container/layout for the application. &lt;br /&gt;
For example, header.html includes the menu bar (displayed on the top of the page):&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
*&amp;lt;nowiki&amp;gt; &amp;lt;div class=&amp;quot;left pull-left&amp;quot;&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*    &amp;lt;nowiki&amp;gt;    &amp;lt;ul class=&amp;quot;navbar-nav nav&amp;quot;&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*        &amp;lt;nowiki&amp;gt;      &amp;lt;li data-ng-repeat=&amp;quot;item in menus.main&amp;quot; ui-route=&amp;quot;/{{item.link}}&amp;quot; ng-class=&amp;quot;{active: $uiRoute}&amp;quot;&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*            &amp;lt;nowiki&amp;gt;         &amp;lt;a mean-token=&amp;quot;item.link&amp;quot; ui-sref='{{item.link}}'&amp;gt;{{item.title}}&amp;lt;/a&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*        &amp;lt;nowiki&amp;gt;     &amp;lt;/li&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*    &amp;lt;nowiki&amp;gt;   &amp;lt;/ul&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*&amp;lt;nowiki&amp;gt; &amp;lt;/div&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Try changing {{item.title}} inside the &amp;lt;a&amp;gt; &amp;lt;/a&amp;gt;tags to &amp;quot;my articles&amp;quot; see what happens to the page.&lt;br /&gt;
* The ui-sref is &amp;quot;href&amp;quot; in ui-route, an AngularJS plugin, try changing {{item.link}} to #!/myarticles, &lt;br /&gt;
* What happens to the application now? When you click on &amp;quot;my articles&amp;quot;?&lt;br /&gt;
&lt;br /&gt;
The page to articles is no longer served!&lt;br /&gt;
&lt;br /&gt;
But how does the framework know which page to serve given a certain url?  The file that's responsible for this (called routing in web development) is in public/articles/routes&lt;br /&gt;
&lt;br /&gt;
open up articles.js found in this folder and find this line:&lt;br /&gt;
&lt;br /&gt;
            .state('all articles', {&lt;br /&gt;
                url: '/articles',&lt;br /&gt;
                templateUrl: 'public/articles/views/list.html',&lt;br /&gt;
                resolve: {&lt;br /&gt;
                    loggedin: checkLoggedin&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
This is ui-route's way of telling the server what to serve the page specified by the templateUrl when it sees &amp;quot;localhost:3000/#!/phones&amp;quot;. &lt;br /&gt;
The #! is a hash prefix used for MEAN to make ajax calls so make sure to include it when coding your views.&lt;br /&gt;
Now try changing the url to &amp;quot;/myarticles&amp;quot;, save and go back to your app, click on &amp;quot;my articles&amp;quot; now, what happens?&lt;br /&gt;
&lt;br /&gt;
*This is important if you want to customize your navigation bar and links. Just remember that each url needs an entry in the route file, in the format of the example above.&lt;br /&gt;
&lt;br /&gt;
= Practice = &lt;br /&gt;
&lt;br /&gt;
Can you implement a view in your myPackage to display all phones injected in the DB? &lt;br /&gt;
Hint: myPackage has the same file structure as the default app.&lt;/div&gt;</summary>
		<author><name>Vigo</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=1728</id>
		<title>Getting MEAN</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=1728"/>
		<updated>2014-05-11T23:36:38Z</updated>

		<summary type="html">&lt;p&gt;Vigo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Installation ===&lt;br /&gt;
To install MEAN, make sure you already have all of the following components installed and configured correctly.&lt;br /&gt;
1. Node.js (should come with npm) &amp;lt;br/&amp;gt;&lt;br /&gt;
To find out if you have node and npm, try checking their versions (may not be the same):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
node --version&lt;br /&gt;
v0.10.25&lt;br /&gt;
npm --version&lt;br /&gt;
1.3.24&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
IF you don't have node.js, install it [http://nodejs.org/ here].&lt;br /&gt;
&lt;br /&gt;
2. Bower&lt;br /&gt;
&lt;br /&gt;
Bower is a web application manager used by MEAN. To install bower, type the following command in your terminal: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;npm i -g bower&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. MongoDB&lt;br /&gt;
To install MongoDB, follow the instructions for your OS [http://docs.mongodb.org/manual/installation/ here].&lt;br /&gt;
&lt;br /&gt;
4. and finally, MEAN&lt;br /&gt;
In your terminal, type:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt; &amp;gt; sudo npm install -g meanio@latest &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Take a moment and read the rest of the [http://mean.io/#!/docs docs] to get familiar with the file structure and idioms.&lt;br /&gt;
&lt;br /&gt;
=== Running the Default App ===&lt;br /&gt;
* Init and run an app. &lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; mean init myApp // create your first app&lt;br /&gt;
&amp;gt; cd myApp &lt;br /&gt;
&amp;gt; npm install // Install dependencies&lt;br /&gt;
&amp;gt; grunt // Launch mean&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Make sure MongoDB is connected and running (if you run into problems, refer to the section on MongoDB)&lt;br /&gt;
&lt;br /&gt;
* Go ahead and explore features of the default Article app (such as logging in, adding/deleting articles).&lt;br /&gt;
&lt;br /&gt;
=== Generating a Package === &lt;br /&gt;
* By now you should know what a package is in MEAN. If you don't, read [http://mean.io/#!/docs this].&lt;br /&gt;
* Try creating a package named myPackage by typing: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; mean package myPackage;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Locate it inside the packages folder:&lt;br /&gt;
* Compare the structure of myPackage folder to that of the default app. Make sure you see both '''public''' and  '''server''' folders and their subfolders.&lt;br /&gt;
* Restart your app, make sure you can see a link to the newly created package.&lt;br /&gt;
&lt;br /&gt;
=== A Closer Look at the App ===&lt;br /&gt;
Take a look at the directory where you app resides, you will see two folders '''public''' and  '''server''', which contain code for the client side and server side respectively.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Models =&lt;br /&gt;
&lt;br /&gt;
Open up article.js in /server/models&lt;br /&gt;
&lt;br /&gt;
MEAN is MVC on the client side and the server side.  Since the model is tied to the backend to MongoDB, you will only see the models folder on the server side, which is normal. &lt;br /&gt;
The models are mongoose models that's why we need to require mongoose (what the following line does):&lt;br /&gt;
&lt;br /&gt;
var mongoose = require('mongoose'), Schema = mongoose.Schema;&lt;br /&gt;
&lt;br /&gt;
The following part then defines the schema:&lt;br /&gt;
&lt;br /&gt;
var ArticleSchema = new Schema({&lt;br /&gt;
    created: {&lt;br /&gt;
        type: Date,&lt;br /&gt;
        default: Date.now&lt;br /&gt;
    },&lt;br /&gt;
    title: {&lt;br /&gt;
        type: String,&lt;br /&gt;
        default: '',&lt;br /&gt;
        trim: true&lt;br /&gt;
    },&lt;br /&gt;
    content: {&lt;br /&gt;
        type: String,&lt;br /&gt;
        default: '',&lt;br /&gt;
        trim: true&lt;br /&gt;
    },&lt;br /&gt;
    user: {&lt;br /&gt;
        type: Schema.ObjectId,&lt;br /&gt;
        ref: 'User'&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
The next part is validations, or criteria an object needs to pass before it can be saved to the DB. &lt;br /&gt;
The following code is to make sure that an article has a title:&lt;br /&gt;
&lt;br /&gt;
ArticleSchema.path('title').validate(function(title) {&lt;br /&gt;
    return title.length;&lt;br /&gt;
}, 'Title cannot be blank');&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Finally, Mongoose allows us to define methods to our data objects as well. &lt;br /&gt;
These are called statics. From the Mongoose doc: Schemas not only define the structure of your document and casting of properties, they also define document instance methods, static Model methods, compound indexes and document lifecycle hooks called middleware.&lt;br /&gt;
The following code defines a method called load for the article schema:&lt;br /&gt;
&lt;br /&gt;
ArticleSchema.statics.load = function(id, cb) {&lt;br /&gt;
    this.findOne({&lt;br /&gt;
        _id: id&lt;br /&gt;
    }).populate('user', 'name username').exec(cb);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
If you have trouble understanding what the code does, review the Mongoose [http://mongoosejs.com/docs/index.html quick start] guide.&lt;br /&gt;
&lt;br /&gt;
= Models Practice = &lt;br /&gt;
Define a schema for a model named '''Phone''', name it phone.js and save it in the corresponding folder in 'myPackage' (hint: /packages/myPackage/server/models/)&lt;br /&gt;
A product needs to have the following fields with specific types. Here is an example of a Phone object can be stored in the MongoDB:&lt;br /&gt;
&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;age&amp;quot;: 0, &lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;motorola-xoom-with-wi-fi&amp;quot;, &lt;br /&gt;
        &amp;quot;imageUrl&amp;quot;: &amp;quot;img/phones/motorola-xoom-with-wi-fi.0.jpg&amp;quot;, &lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;Motorola XOOM\u2122 with Wi-Fi&amp;quot;, &lt;br /&gt;
        &amp;quot;snippet&amp;quot;: &amp;quot;The Next, Next Generation\r\n\r\nExperience the future with Motorola XOOM with Wi-Fi, the world's first tablet powered by Android 3.0 (Honeycomb).&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
This is taken from phones.json used by the AngularJS tutorial. If you have gone through the tutorial, you should have realized that instead of using a DB, json files were used to simplify the tutorial.&lt;br /&gt;
Find phones.json in /app/phones in the angular tutorial folder and try importing its content to MongoDB so you can use them in your current MEAN package.&lt;br /&gt;
&lt;br /&gt;
*Run '''mongod''' and connect to mongo shell (mongo --shell), then type &amp;quot;use mean-dev&amp;quot; to switch to database used by mean.&lt;br /&gt;
*Type  mongoimport --db mean-dev --collection phones --type json --file ''&amp;lt;path to phones.json&amp;gt;'' --jsonArray&lt;br /&gt;
*Type show collections to see if phones are added to your database, type coll = db.phones to see the content of the file.&lt;br /&gt;
&lt;br /&gt;
= Controllers =&lt;br /&gt;
&lt;br /&gt;
You'll find a controllers folder on both the server side and the client side.  &lt;br /&gt;
* The client side controllers are part of the Angular MVC scheme that contains client side logic and may issue requests to the server.&lt;br /&gt;
* The server side controllers deal with the models and requests from the client side.&lt;br /&gt;
&lt;br /&gt;
'''Server side:'''&lt;br /&gt;
&lt;br /&gt;
* Find articles.js in the controllers folder. Try to understand what each part does. &lt;br /&gt;
* Find articles.js in /server/routes/middlewares &lt;br /&gt;
You'll see that it requires the articles controller and its methods for querying the database.&lt;br /&gt;
&lt;br /&gt;
The first section requires the articles controller, which defines different methods &lt;br /&gt;
&lt;br /&gt;
For example:     &lt;br /&gt;
app.route('/articles')&lt;br /&gt;
        .get(articles.all)&lt;br /&gt;
tells the server to use a method named &amp;quot;all&amp;quot; in the articles controller when the url is pointed to /articles.&lt;br /&gt;
&lt;br /&gt;
*Go to http://localhost:3000/articles, what do you see? Does it make sense?&lt;br /&gt;
&lt;br /&gt;
'''Client side:''' open up articles.js in /public/articles/controllers&lt;br /&gt;
Compare the functions defined in ArticlesController, can you find the corresponding functions on the server side implementation of articles controller? &lt;br /&gt;
&lt;br /&gt;
Here is a diagram to help you under stand how this works:&lt;br /&gt;
&lt;br /&gt;
[[File:pic]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Views &amp;amp; Routing =&lt;br /&gt;
Let's switch to the public folder where the views reside. &lt;br /&gt;
&lt;br /&gt;
Go to public/articles/views, open up list.html:&lt;br /&gt;
The first line tells the framework that  ArticlesController is responsible for this particular view and when this view is loaded, use find() to initiate data binding.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;section data-ng-controller=&amp;quot;ArticlesController&amp;quot; data-ng-init=&amp;quot;find()&amp;quot;&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Feel free to take a look at what find() does. Make sure you understand that what find() does is actually done by the backend, where a corresponding find() is written (as mentioned above).&lt;br /&gt;
Hopefully you have a better understanding of how these technologies all work together now.&lt;br /&gt;
&lt;br /&gt;
Review the AngularJS section if you have any questions regarding the view data binding.&lt;br /&gt;
&lt;br /&gt;
The view files in articles/views only defines the code for displaying the articles, where does the navigation bar gets defined.&lt;br /&gt;
The answer is in /public/system. &lt;br /&gt;
*The .html files in public/system/views provide a container/layout for the application. &lt;br /&gt;
For example, header.html includes the menu bar (displayed on the top of the page):&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
*&amp;lt;nowiki&amp;gt; &amp;lt;div class=&amp;quot;left pull-left&amp;quot;&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*    &amp;lt;nowiki&amp;gt;    &amp;lt;ul class=&amp;quot;navbar-nav nav&amp;quot;&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*        &amp;lt;nowiki&amp;gt;      &amp;lt;li data-ng-repeat=&amp;quot;item in menus.main&amp;quot; ui-route=&amp;quot;/{{item.link}}&amp;quot; ng-class=&amp;quot;{active: $uiRoute}&amp;quot;&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*            &amp;lt;nowiki&amp;gt;         &amp;lt;a mean-token=&amp;quot;item.link&amp;quot; ui-sref='{{item.link}}'&amp;gt;{{item.title}}&amp;lt;/a&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*        &amp;lt;nowiki&amp;gt;     &amp;lt;/li&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*    &amp;lt;nowiki&amp;gt;   &amp;lt;/ul&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*&amp;lt;nowiki&amp;gt; &amp;lt;/div&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Try changing {{item.title}} inside the &amp;lt;a&amp;gt; &amp;lt;/a&amp;gt;tags to &amp;quot;my articles&amp;quot; see what happens to the page.&lt;br /&gt;
* The ui-sref is &amp;quot;href&amp;quot; in ui-route, an AngularJS plugin, try changing {{item.link}} to #!/myarticles, &lt;br /&gt;
* What happens to the application now? When you click on &amp;quot;my articles&amp;quot;?&lt;br /&gt;
&lt;br /&gt;
The page to articles is no longer served!&lt;br /&gt;
&lt;br /&gt;
But how does the framework know which page to serve given a certain url?  The file that's responsible for this (called routing in web development) is in public/articles/routes&lt;br /&gt;
&lt;br /&gt;
open up articles.js found in this folder and find this line:&lt;br /&gt;
&lt;br /&gt;
            .state('all articles', {&lt;br /&gt;
                url: '/articles',&lt;br /&gt;
                templateUrl: 'public/articles/views/list.html',&lt;br /&gt;
                resolve: {&lt;br /&gt;
                    loggedin: checkLoggedin&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
This is ui-route's way of telling the server what to serve the page specified by the templateUrl when it sees &amp;quot;localhost:3000/#!/phones&amp;quot;. &lt;br /&gt;
The #! is a hash prefix used for MEAN to make ajax calls so make sure to include it when coding your views.&lt;br /&gt;
Now try changing the url to &amp;quot;/myarticles&amp;quot;, save and go back to your app, click on &amp;quot;my articles&amp;quot; now, what happens?&lt;br /&gt;
&lt;br /&gt;
*This is important if you want to customize your navigation bar and links. Just remember that each url needs an entry in the route file, in the format of the example above.&lt;br /&gt;
&lt;br /&gt;
= Practice = &lt;br /&gt;
&lt;br /&gt;
Can you implement a view in your myPackage to display all phones injected in the DB? &lt;br /&gt;
Hint: myPackage has the same file structure as the default app.&lt;/div&gt;</summary>
		<author><name>Vigo</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=1727</id>
		<title>Getting MEAN</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=1727"/>
		<updated>2014-05-11T23:33:41Z</updated>

		<summary type="html">&lt;p&gt;Vigo: /* Running the Default App */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Installation ===&lt;br /&gt;
To install MEAN, make sure you already have all of the following components installed and configured correctly.&lt;br /&gt;
1. Node.js (should come with npm) &amp;lt;br/&amp;gt;&lt;br /&gt;
To find out if you have node and npm, try checking their versions (may not be the same):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
node --version&lt;br /&gt;
v0.10.25&lt;br /&gt;
npm --version&lt;br /&gt;
1.3.24&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
IF you don't have node.js, install it [http://nodejs.org/ here].&lt;br /&gt;
&lt;br /&gt;
2. Bower&lt;br /&gt;
&lt;br /&gt;
Bower is a web application manager used by MEAN. To install bower, type the following command in your terminal: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;npm i -g bower&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. MongoDB&lt;br /&gt;
To install MongoDB, follow the instructions for your OS [http://docs.mongodb.org/manual/installation/ here].&lt;br /&gt;
&lt;br /&gt;
4. and finally, MEAN&lt;br /&gt;
In your terminal, type:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt; &amp;gt; sudo npm install -g meanio@latest &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Take a moment and read the rest of the [http://mean.io/#!/docs docs] to get familiar with the file structure and idioms.&lt;br /&gt;
&lt;br /&gt;
=== Running the Default App ===&lt;br /&gt;
* Init and run an app. &lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; mean init myApp // create your first app&lt;br /&gt;
&amp;gt; cd myApp &lt;br /&gt;
&amp;gt; npm install // Install dependencies&lt;br /&gt;
&amp;gt; grunt // Launch mean&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
Make sure MongoDB is connected and running (if you run into problems, refer to the section on MongoDB)&lt;br /&gt;
&lt;br /&gt;
* Go ahead and explore features of the default Article app (such as logging in, adding/deleting articles).&lt;br /&gt;
&lt;br /&gt;
=== Generating a Package === &lt;br /&gt;
* By now you should know what a package is in MEAN. If you don't, read [http://mean.io/#!/docs this].&lt;br /&gt;
* Try creating a package named myPackage and locate it inside the packages folder&lt;br /&gt;
* Compare the structure of myPackage folder to that of the default app. Make sure you see both '''public''' and  '''server''' folders and their subfolders.&lt;br /&gt;
* Restart your app, make sure you can see a link to the newly created package.&lt;br /&gt;
&lt;br /&gt;
=== A Closer Look at the App ===&lt;br /&gt;
Take a look at the directory where you app resides, you will see two folders '''public''' and  '''server''', which contain code for the client side and server side respectively.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Models =&lt;br /&gt;
&lt;br /&gt;
Open up article.js in /server/models&lt;br /&gt;
&lt;br /&gt;
MEAN is MVC on the client side and the server side.  Since the model is tied to the backend to MongoDB, you will only see the models folder on the server side, which is normal. &lt;br /&gt;
The models are mongoose models that's why we need to require mongoose (what the following line does):&lt;br /&gt;
&lt;br /&gt;
var mongoose = require('mongoose'), Schema = mongoose.Schema;&lt;br /&gt;
&lt;br /&gt;
The following part then defines the schema:&lt;br /&gt;
&lt;br /&gt;
var ArticleSchema = new Schema({&lt;br /&gt;
    created: {&lt;br /&gt;
        type: Date,&lt;br /&gt;
        default: Date.now&lt;br /&gt;
    },&lt;br /&gt;
    title: {&lt;br /&gt;
        type: String,&lt;br /&gt;
        default: '',&lt;br /&gt;
        trim: true&lt;br /&gt;
    },&lt;br /&gt;
    content: {&lt;br /&gt;
        type: String,&lt;br /&gt;
        default: '',&lt;br /&gt;
        trim: true&lt;br /&gt;
    },&lt;br /&gt;
    user: {&lt;br /&gt;
        type: Schema.ObjectId,&lt;br /&gt;
        ref: 'User'&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
The next part is validations, or criteria an object needs to pass before it can be saved to the DB. &lt;br /&gt;
The following code is to make sure that an article has a title:&lt;br /&gt;
&lt;br /&gt;
ArticleSchema.path('title').validate(function(title) {&lt;br /&gt;
    return title.length;&lt;br /&gt;
}, 'Title cannot be blank');&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Finally, Mongoose allows us to define methods to our data objects as well. &lt;br /&gt;
These are called statics. From the Mongoose doc: Schemas not only define the structure of your document and casting of properties, they also define document instance methods, static Model methods, compound indexes and document lifecycle hooks called middleware.&lt;br /&gt;
The following code defines a method called load for the article schema:&lt;br /&gt;
&lt;br /&gt;
ArticleSchema.statics.load = function(id, cb) {&lt;br /&gt;
    this.findOne({&lt;br /&gt;
        _id: id&lt;br /&gt;
    }).populate('user', 'name username').exec(cb);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
If you have trouble understanding what the code does, review the Mongoose [http://mongoosejs.com/docs/index.html quick start] guide.&lt;br /&gt;
&lt;br /&gt;
= Models Practice = &lt;br /&gt;
Define a schema for a model named '''Phone''', name it phone.js and save it in the corresponding folder in 'myPackage' (hint: /packages/myPackage/server/models/)&lt;br /&gt;
A product needs to have the following fields with specific types. Here is an example of a Phone object can be stored in the MongoDB:&lt;br /&gt;
&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;age&amp;quot;: 0, &lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;motorola-xoom-with-wi-fi&amp;quot;, &lt;br /&gt;
        &amp;quot;imageUrl&amp;quot;: &amp;quot;img/phones/motorola-xoom-with-wi-fi.0.jpg&amp;quot;, &lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;Motorola XOOM\u2122 with Wi-Fi&amp;quot;, &lt;br /&gt;
        &amp;quot;snippet&amp;quot;: &amp;quot;The Next, Next Generation\r\n\r\nExperience the future with Motorola XOOM with Wi-Fi, the world's first tablet powered by Android 3.0 (Honeycomb).&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
This is taken from phones.json used by the AngularJS tutorial. If you have gone through the tutorial, you should have realized that instead of using a DB, json files were used to simplify the tutorial.&lt;br /&gt;
Find phones.json in /app/phones in the angular tutorial folder and try importing its content to MongoDB so you can use them in your current MEAN package.&lt;br /&gt;
&lt;br /&gt;
*Run '''mongod''' and connect to mongo shell (mongo --shell), then type &amp;quot;use mean-dev&amp;quot; to switch to database used by mean.&lt;br /&gt;
*Type  mongoimport --db mean-dev --collection phones --type json --file ''&amp;lt;path to phones.json&amp;gt;'' --jsonArray&lt;br /&gt;
*Type show collections to see if phones are added to your database, type coll = db.phones to see the content of the file.&lt;br /&gt;
&lt;br /&gt;
= Controllers =&lt;br /&gt;
&lt;br /&gt;
You'll find a controllers folder on both the server side and the client side.  &lt;br /&gt;
* The client side controllers are part of the Angular MVC scheme that contains client side logic and may issue requests to the server.&lt;br /&gt;
* The server side controllers deal with the models and requests from the client side.&lt;br /&gt;
&lt;br /&gt;
'''Server side:'''&lt;br /&gt;
&lt;br /&gt;
* Find articles.js in the controllers folder. Try to understand what each part does. &lt;br /&gt;
* Find articles.js in /server/routes/middlewares &lt;br /&gt;
You'll see that it requires the articles controller and its methods for querying the database.&lt;br /&gt;
&lt;br /&gt;
The first section requires the articles controller, which defines different methods &lt;br /&gt;
&lt;br /&gt;
For example:     &lt;br /&gt;
app.route('/articles')&lt;br /&gt;
        .get(articles.all)&lt;br /&gt;
tells the server to use a method named &amp;quot;all&amp;quot; in the articles controller when the url is pointed to /articles.&lt;br /&gt;
&lt;br /&gt;
*Go to http://localhost:3000/articles, what do you see? Does it make sense?&lt;br /&gt;
&lt;br /&gt;
'''Client side:''' open up articles.js in /public/articles/controllers&lt;br /&gt;
Compare the functions defined in ArticlesController, can you find the corresponding functions on the server side implementation of articles controller? &lt;br /&gt;
&lt;br /&gt;
Here is a diagram to help you under stand how this works:&lt;br /&gt;
&lt;br /&gt;
[[File:pic]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Views &amp;amp; Routing =&lt;br /&gt;
Let's switch to the public folder where the views reside. &lt;br /&gt;
&lt;br /&gt;
Go to public/articles/views, open up list.html:&lt;br /&gt;
The first line tells the framework that  ArticlesController is responsible for this particular view and when this view is loaded, use find() to initiate data binding.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;section data-ng-controller=&amp;quot;ArticlesController&amp;quot; data-ng-init=&amp;quot;find()&amp;quot;&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Feel free to take a look at what find() does. Make sure you understand that what find() does is actually done by the backend, where a corresponding find() is written (as mentioned above).&lt;br /&gt;
Hopefully you have a better understanding of how these technologies all work together now.&lt;br /&gt;
&lt;br /&gt;
Review the AngularJS section if you have any questions regarding the view data binding.&lt;br /&gt;
&lt;br /&gt;
The view files in articles/views only defines the code for displaying the articles, where does the navigation bar gets defined.&lt;br /&gt;
The answer is in /public/system. &lt;br /&gt;
*The .html files in public/system/views provide a container/layout for the application. &lt;br /&gt;
For example, header.html includes the menu bar (displayed on the top of the page):&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
*&amp;lt;nowiki&amp;gt; &amp;lt;div class=&amp;quot;left pull-left&amp;quot;&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*    &amp;lt;nowiki&amp;gt;    &amp;lt;ul class=&amp;quot;navbar-nav nav&amp;quot;&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*        &amp;lt;nowiki&amp;gt;      &amp;lt;li data-ng-repeat=&amp;quot;item in menus.main&amp;quot; ui-route=&amp;quot;/{{item.link}}&amp;quot; ng-class=&amp;quot;{active: $uiRoute}&amp;quot;&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*            &amp;lt;nowiki&amp;gt;         &amp;lt;a mean-token=&amp;quot;item.link&amp;quot; ui-sref='{{item.link}}'&amp;gt;{{item.title}}&amp;lt;/a&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*        &amp;lt;nowiki&amp;gt;     &amp;lt;/li&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*    &amp;lt;nowiki&amp;gt;   &amp;lt;/ul&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*&amp;lt;nowiki&amp;gt; &amp;lt;/div&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Try changing {{item.title}} inside the &amp;lt;a&amp;gt; &amp;lt;/a&amp;gt;tags to &amp;quot;my articles&amp;quot; see what happens to the page.&lt;br /&gt;
* The ui-sref is &amp;quot;href&amp;quot; in ui-route, an AngularJS plugin, try changing {{item.link}} to #!/myarticles, &lt;br /&gt;
* What happens to the application now? When you click on &amp;quot;my articles&amp;quot;?&lt;br /&gt;
&lt;br /&gt;
The page to articles is no longer served!&lt;br /&gt;
&lt;br /&gt;
But how does the framework know which page to serve given a certain url?  The file that's responsible for this (called routing in web development) is in public/articles/routes&lt;br /&gt;
&lt;br /&gt;
open up articles.js found in this folder and find this line:&lt;br /&gt;
&lt;br /&gt;
            .state('all articles', {&lt;br /&gt;
                url: '/articles',&lt;br /&gt;
                templateUrl: 'public/articles/views/list.html',&lt;br /&gt;
                resolve: {&lt;br /&gt;
                    loggedin: checkLoggedin&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
This is ui-route's way of telling the server what to serve the page specified by the templateUrl when it sees &amp;quot;localhost:3000/#!/phones&amp;quot;. &lt;br /&gt;
The #! is a hash prefix used for MEAN to make ajax calls so make sure to include it when coding your views.&lt;br /&gt;
Now try changing the url to &amp;quot;/myarticles&amp;quot;, save and go back to your app, click on &amp;quot;my articles&amp;quot; now, what happens?&lt;br /&gt;
&lt;br /&gt;
*This is important if you want to customize your navigation bar and links. Just remember that each url needs an entry in the route file, in the format of the example above.&lt;br /&gt;
&lt;br /&gt;
= Practice = &lt;br /&gt;
&lt;br /&gt;
Can you implement a view in your myPackage to display all phones injected in the DB? &lt;br /&gt;
Hint: myPackage has the same file structure as the default app.&lt;/div&gt;</summary>
		<author><name>Vigo</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=1726</id>
		<title>Getting MEAN</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=1726"/>
		<updated>2014-05-11T23:30:44Z</updated>

		<summary type="html">&lt;p&gt;Vigo: /* Installation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Installation ===&lt;br /&gt;
To install MEAN, make sure you already have all of the following components installed and configured correctly.&lt;br /&gt;
1. Node.js (should come with npm) &amp;lt;br/&amp;gt;&lt;br /&gt;
To find out if you have node and npm, try checking their versions (may not be the same):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
node --version&lt;br /&gt;
v0.10.25&lt;br /&gt;
npm --version&lt;br /&gt;
1.3.24&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
IF you don't have node.js, install it [http://nodejs.org/ here].&lt;br /&gt;
&lt;br /&gt;
2. Bower&lt;br /&gt;
&lt;br /&gt;
Bower is a web application manager used by MEAN. To install bower, type the following command in your terminal: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;npm i -g bower&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. MongoDB&lt;br /&gt;
To install MongoDB, follow the instructions for your OS [http://docs.mongodb.org/manual/installation/ here].&lt;br /&gt;
&lt;br /&gt;
4. and finally, MEAN&lt;br /&gt;
In your terminal, type:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt; &amp;gt; sudo npm install -g meanio@latest &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Take a moment and read the rest of the [http://mean.io/#!/docs docs] to get familiar with the file structure and idioms.&lt;br /&gt;
&lt;br /&gt;
=== Running the Default App ===&lt;br /&gt;
* Init and run an app. Make sure MongoDB is connected and running (if you run into problems, refer to the section on MongoDB)&lt;br /&gt;
* Explore features of the default Article app (such as logging in, adding/deleting articles).&lt;br /&gt;
&lt;br /&gt;
=== Generating a Package === &lt;br /&gt;
* By now you should know what a package is in MEAN. If you don't, read [http://mean.io/#!/docs this].&lt;br /&gt;
* Try creating a package named myPackage and locate it inside the packages folder&lt;br /&gt;
* Compare the structure of myPackage folder to that of the default app. Make sure you see both '''public''' and  '''server''' folders and their subfolders.&lt;br /&gt;
* Restart your app, make sure you can see a link to the newly created package.&lt;br /&gt;
&lt;br /&gt;
=== A Closer Look at the App ===&lt;br /&gt;
Take a look at the directory where you app resides, you will see two folders '''public''' and  '''server''', which contain code for the client side and server side respectively.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Models =&lt;br /&gt;
&lt;br /&gt;
Open up article.js in /server/models&lt;br /&gt;
&lt;br /&gt;
MEAN is MVC on the client side and the server side.  Since the model is tied to the backend to MongoDB, you will only see the models folder on the server side, which is normal. &lt;br /&gt;
The models are mongoose models that's why we need to require mongoose (what the following line does):&lt;br /&gt;
&lt;br /&gt;
var mongoose = require('mongoose'), Schema = mongoose.Schema;&lt;br /&gt;
&lt;br /&gt;
The following part then defines the schema:&lt;br /&gt;
&lt;br /&gt;
var ArticleSchema = new Schema({&lt;br /&gt;
    created: {&lt;br /&gt;
        type: Date,&lt;br /&gt;
        default: Date.now&lt;br /&gt;
    },&lt;br /&gt;
    title: {&lt;br /&gt;
        type: String,&lt;br /&gt;
        default: '',&lt;br /&gt;
        trim: true&lt;br /&gt;
    },&lt;br /&gt;
    content: {&lt;br /&gt;
        type: String,&lt;br /&gt;
        default: '',&lt;br /&gt;
        trim: true&lt;br /&gt;
    },&lt;br /&gt;
    user: {&lt;br /&gt;
        type: Schema.ObjectId,&lt;br /&gt;
        ref: 'User'&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
The next part is validations, or criteria an object needs to pass before it can be saved to the DB. &lt;br /&gt;
The following code is to make sure that an article has a title:&lt;br /&gt;
&lt;br /&gt;
ArticleSchema.path('title').validate(function(title) {&lt;br /&gt;
    return title.length;&lt;br /&gt;
}, 'Title cannot be blank');&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Finally, Mongoose allows us to define methods to our data objects as well. &lt;br /&gt;
These are called statics. From the Mongoose doc: Schemas not only define the structure of your document and casting of properties, they also define document instance methods, static Model methods, compound indexes and document lifecycle hooks called middleware.&lt;br /&gt;
The following code defines a method called load for the article schema:&lt;br /&gt;
&lt;br /&gt;
ArticleSchema.statics.load = function(id, cb) {&lt;br /&gt;
    this.findOne({&lt;br /&gt;
        _id: id&lt;br /&gt;
    }).populate('user', 'name username').exec(cb);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
If you have trouble understanding what the code does, review the Mongoose [http://mongoosejs.com/docs/index.html quick start] guide.&lt;br /&gt;
&lt;br /&gt;
= Models Practice = &lt;br /&gt;
Define a schema for a model named '''Phone''', name it phone.js and save it in the corresponding folder in 'myPackage' (hint: /packages/myPackage/server/models/)&lt;br /&gt;
A product needs to have the following fields with specific types. Here is an example of a Phone object can be stored in the MongoDB:&lt;br /&gt;
&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;age&amp;quot;: 0, &lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;motorola-xoom-with-wi-fi&amp;quot;, &lt;br /&gt;
        &amp;quot;imageUrl&amp;quot;: &amp;quot;img/phones/motorola-xoom-with-wi-fi.0.jpg&amp;quot;, &lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;Motorola XOOM\u2122 with Wi-Fi&amp;quot;, &lt;br /&gt;
        &amp;quot;snippet&amp;quot;: &amp;quot;The Next, Next Generation\r\n\r\nExperience the future with Motorola XOOM with Wi-Fi, the world's first tablet powered by Android 3.0 (Honeycomb).&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
This is taken from phones.json used by the AngularJS tutorial. If you have gone through the tutorial, you should have realized that instead of using a DB, json files were used to simplify the tutorial.&lt;br /&gt;
Find phones.json in /app/phones in the angular tutorial folder and try importing its content to MongoDB so you can use them in your current MEAN package.&lt;br /&gt;
&lt;br /&gt;
*Run '''mongod''' and connect to mongo shell (mongo --shell), then type &amp;quot;use mean-dev&amp;quot; to switch to database used by mean.&lt;br /&gt;
*Type  mongoimport --db mean-dev --collection phones --type json --file ''&amp;lt;path to phones.json&amp;gt;'' --jsonArray&lt;br /&gt;
*Type show collections to see if phones are added to your database, type coll = db.phones to see the content of the file.&lt;br /&gt;
&lt;br /&gt;
= Controllers =&lt;br /&gt;
&lt;br /&gt;
You'll find a controllers folder on both the server side and the client side.  &lt;br /&gt;
* The client side controllers are part of the Angular MVC scheme that contains client side logic and may issue requests to the server.&lt;br /&gt;
* The server side controllers deal with the models and requests from the client side.&lt;br /&gt;
&lt;br /&gt;
'''Server side:'''&lt;br /&gt;
&lt;br /&gt;
* Find articles.js in the controllers folder. Try to understand what each part does. &lt;br /&gt;
* Find articles.js in /server/routes/middlewares &lt;br /&gt;
You'll see that it requires the articles controller and its methods for querying the database.&lt;br /&gt;
&lt;br /&gt;
The first section requires the articles controller, which defines different methods &lt;br /&gt;
&lt;br /&gt;
For example:     &lt;br /&gt;
app.route('/articles')&lt;br /&gt;
        .get(articles.all)&lt;br /&gt;
tells the server to use a method named &amp;quot;all&amp;quot; in the articles controller when the url is pointed to /articles.&lt;br /&gt;
&lt;br /&gt;
*Go to http://localhost:3000/articles, what do you see? Does it make sense?&lt;br /&gt;
&lt;br /&gt;
'''Client side:''' open up articles.js in /public/articles/controllers&lt;br /&gt;
Compare the functions defined in ArticlesController, can you find the corresponding functions on the server side implementation of articles controller? &lt;br /&gt;
&lt;br /&gt;
Here is a diagram to help you under stand how this works:&lt;br /&gt;
&lt;br /&gt;
[[File:pic]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Views &amp;amp; Routing =&lt;br /&gt;
Let's switch to the public folder where the views reside. &lt;br /&gt;
&lt;br /&gt;
Go to public/articles/views, open up list.html:&lt;br /&gt;
The first line tells the framework that  ArticlesController is responsible for this particular view and when this view is loaded, use find() to initiate data binding.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;section data-ng-controller=&amp;quot;ArticlesController&amp;quot; data-ng-init=&amp;quot;find()&amp;quot;&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Feel free to take a look at what find() does. Make sure you understand that what find() does is actually done by the backend, where a corresponding find() is written (as mentioned above).&lt;br /&gt;
Hopefully you have a better understanding of how these technologies all work together now.&lt;br /&gt;
&lt;br /&gt;
Review the AngularJS section if you have any questions regarding the view data binding.&lt;br /&gt;
&lt;br /&gt;
The view files in articles/views only defines the code for displaying the articles, where does the navigation bar gets defined.&lt;br /&gt;
The answer is in /public/system. &lt;br /&gt;
*The .html files in public/system/views provide a container/layout for the application. &lt;br /&gt;
For example, header.html includes the menu bar (displayed on the top of the page):&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
*&amp;lt;nowiki&amp;gt; &amp;lt;div class=&amp;quot;left pull-left&amp;quot;&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*    &amp;lt;nowiki&amp;gt;    &amp;lt;ul class=&amp;quot;navbar-nav nav&amp;quot;&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*        &amp;lt;nowiki&amp;gt;      &amp;lt;li data-ng-repeat=&amp;quot;item in menus.main&amp;quot; ui-route=&amp;quot;/{{item.link}}&amp;quot; ng-class=&amp;quot;{active: $uiRoute}&amp;quot;&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*            &amp;lt;nowiki&amp;gt;         &amp;lt;a mean-token=&amp;quot;item.link&amp;quot; ui-sref='{{item.link}}'&amp;gt;{{item.title}}&amp;lt;/a&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*        &amp;lt;nowiki&amp;gt;     &amp;lt;/li&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*    &amp;lt;nowiki&amp;gt;   &amp;lt;/ul&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*&amp;lt;nowiki&amp;gt; &amp;lt;/div&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Try changing {{item.title}} inside the &amp;lt;a&amp;gt; &amp;lt;/a&amp;gt;tags to &amp;quot;my articles&amp;quot; see what happens to the page.&lt;br /&gt;
* The ui-sref is &amp;quot;href&amp;quot; in ui-route, an AngularJS plugin, try changing {{item.link}} to #!/myarticles, &lt;br /&gt;
* What happens to the application now? When you click on &amp;quot;my articles&amp;quot;?&lt;br /&gt;
&lt;br /&gt;
The page to articles is no longer served!&lt;br /&gt;
&lt;br /&gt;
But how does the framework know which page to serve given a certain url?  The file that's responsible for this (called routing in web development) is in public/articles/routes&lt;br /&gt;
&lt;br /&gt;
open up articles.js found in this folder and find this line:&lt;br /&gt;
&lt;br /&gt;
            .state('all articles', {&lt;br /&gt;
                url: '/articles',&lt;br /&gt;
                templateUrl: 'public/articles/views/list.html',&lt;br /&gt;
                resolve: {&lt;br /&gt;
                    loggedin: checkLoggedin&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
This is ui-route's way of telling the server what to serve the page specified by the templateUrl when it sees &amp;quot;localhost:3000/#!/phones&amp;quot;. &lt;br /&gt;
The #! is a hash prefix used for MEAN to make ajax calls so make sure to include it when coding your views.&lt;br /&gt;
Now try changing the url to &amp;quot;/myarticles&amp;quot;, save and go back to your app, click on &amp;quot;my articles&amp;quot; now, what happens?&lt;br /&gt;
&lt;br /&gt;
*This is important if you want to customize your navigation bar and links. Just remember that each url needs an entry in the route file, in the format of the example above.&lt;br /&gt;
&lt;br /&gt;
= Practice = &lt;br /&gt;
&lt;br /&gt;
Can you implement a view in your myPackage to display all phones injected in the DB? &lt;br /&gt;
Hint: myPackage has the same file structure as the default app.&lt;/div&gt;</summary>
		<author><name>Vigo</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=1725</id>
		<title>Getting MEAN</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=1725"/>
		<updated>2014-05-11T23:27:11Z</updated>

		<summary type="html">&lt;p&gt;Vigo: /* Installation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Installation ===&lt;br /&gt;
To install MEAN, make sure you already have all of the following components installed and configured correctly.&lt;br /&gt;
1. Node.js (should come with npm) &lt;br /&gt;
To find out if you have node and npm, type node --version and npm --version in your terminal.&lt;br /&gt;
&lt;br /&gt;
you should see something like&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
node --version&lt;br /&gt;
v0.10.25&lt;br /&gt;
npm --version&lt;br /&gt;
1.3.24&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
IF you don't have node.js, install it [http://nodejs.org/ here].&lt;br /&gt;
&lt;br /&gt;
2. Bower&lt;br /&gt;
&lt;br /&gt;
Bower is a web application manager used by MEAN. To install bower, simply type &amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;npm i -g bower&amp;lt;/source&amp;gt; in the terminal.  &lt;br /&gt;
&lt;br /&gt;
3. MongoDB&lt;br /&gt;
To install MongoDB, follow the instructions for your OS [http://docs.mongodb.org/manual/installation/ here].&lt;br /&gt;
&lt;br /&gt;
4. and finally, MEAN&lt;br /&gt;
In your terminal, type:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt; &amp;gt; sudo npm install -g meanio@latest &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Take a moment and read the rest of the [http://mean.io/#!/docs docs] to get familiar with the file structure and idioms.&lt;br /&gt;
&lt;br /&gt;
=== Running the Default App ===&lt;br /&gt;
* Init and run an app. Make sure MongoDB is connected and running (if you run into problems, refer to the section on MongoDB)&lt;br /&gt;
* Explore features of the default Article app (such as logging in, adding/deleting articles).&lt;br /&gt;
&lt;br /&gt;
=== Generating a Package === &lt;br /&gt;
* By now you should know what a package is in MEAN. If you don't, read [http://mean.io/#!/docs this].&lt;br /&gt;
* Try creating a package named myPackage and locate it inside the packages folder&lt;br /&gt;
* Compare the structure of myPackage folder to that of the default app. Make sure you see both '''public''' and  '''server''' folders and their subfolders.&lt;br /&gt;
* Restart your app, make sure you can see a link to the newly created package.&lt;br /&gt;
&lt;br /&gt;
=== A Closer Look at the App ===&lt;br /&gt;
Take a look at the directory where you app resides, you will see two folders '''public''' and  '''server''', which contain code for the client side and server side respectively.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Models =&lt;br /&gt;
&lt;br /&gt;
Open up article.js in /server/models&lt;br /&gt;
&lt;br /&gt;
MEAN is MVC on the client side and the server side.  Since the model is tied to the backend to MongoDB, you will only see the models folder on the server side, which is normal. &lt;br /&gt;
The models are mongoose models that's why we need to require mongoose (what the following line does):&lt;br /&gt;
&lt;br /&gt;
var mongoose = require('mongoose'), Schema = mongoose.Schema;&lt;br /&gt;
&lt;br /&gt;
The following part then defines the schema:&lt;br /&gt;
&lt;br /&gt;
var ArticleSchema = new Schema({&lt;br /&gt;
    created: {&lt;br /&gt;
        type: Date,&lt;br /&gt;
        default: Date.now&lt;br /&gt;
    },&lt;br /&gt;
    title: {&lt;br /&gt;
        type: String,&lt;br /&gt;
        default: '',&lt;br /&gt;
        trim: true&lt;br /&gt;
    },&lt;br /&gt;
    content: {&lt;br /&gt;
        type: String,&lt;br /&gt;
        default: '',&lt;br /&gt;
        trim: true&lt;br /&gt;
    },&lt;br /&gt;
    user: {&lt;br /&gt;
        type: Schema.ObjectId,&lt;br /&gt;
        ref: 'User'&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
The next part is validations, or criteria an object needs to pass before it can be saved to the DB. &lt;br /&gt;
The following code is to make sure that an article has a title:&lt;br /&gt;
&lt;br /&gt;
ArticleSchema.path('title').validate(function(title) {&lt;br /&gt;
    return title.length;&lt;br /&gt;
}, 'Title cannot be blank');&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Finally, Mongoose allows us to define methods to our data objects as well. &lt;br /&gt;
These are called statics. From the Mongoose doc: Schemas not only define the structure of your document and casting of properties, they also define document instance methods, static Model methods, compound indexes and document lifecycle hooks called middleware.&lt;br /&gt;
The following code defines a method called load for the article schema:&lt;br /&gt;
&lt;br /&gt;
ArticleSchema.statics.load = function(id, cb) {&lt;br /&gt;
    this.findOne({&lt;br /&gt;
        _id: id&lt;br /&gt;
    }).populate('user', 'name username').exec(cb);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
If you have trouble understanding what the code does, review the Mongoose [http://mongoosejs.com/docs/index.html quick start] guide.&lt;br /&gt;
&lt;br /&gt;
= Models Practice = &lt;br /&gt;
Define a schema for a model named '''Phone''', name it phone.js and save it in the corresponding folder in 'myPackage' (hint: /packages/myPackage/server/models/)&lt;br /&gt;
A product needs to have the following fields with specific types. Here is an example of a Phone object can be stored in the MongoDB:&lt;br /&gt;
&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;age&amp;quot;: 0, &lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;motorola-xoom-with-wi-fi&amp;quot;, &lt;br /&gt;
        &amp;quot;imageUrl&amp;quot;: &amp;quot;img/phones/motorola-xoom-with-wi-fi.0.jpg&amp;quot;, &lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;Motorola XOOM\u2122 with Wi-Fi&amp;quot;, &lt;br /&gt;
        &amp;quot;snippet&amp;quot;: &amp;quot;The Next, Next Generation\r\n\r\nExperience the future with Motorola XOOM with Wi-Fi, the world's first tablet powered by Android 3.0 (Honeycomb).&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
This is taken from phones.json used by the AngularJS tutorial. If you have gone through the tutorial, you should have realized that instead of using a DB, json files were used to simplify the tutorial.&lt;br /&gt;
Find phones.json in /app/phones in the angular tutorial folder and try importing its content to MongoDB so you can use them in your current MEAN package.&lt;br /&gt;
&lt;br /&gt;
*Run '''mongod''' and connect to mongo shell (mongo --shell), then type &amp;quot;use mean-dev&amp;quot; to switch to database used by mean.&lt;br /&gt;
*Type  mongoimport --db mean-dev --collection phones --type json --file ''&amp;lt;path to phones.json&amp;gt;'' --jsonArray&lt;br /&gt;
*Type show collections to see if phones are added to your database, type coll = db.phones to see the content of the file.&lt;br /&gt;
&lt;br /&gt;
= Controllers =&lt;br /&gt;
&lt;br /&gt;
You'll find a controllers folder on both the server side and the client side.  &lt;br /&gt;
* The client side controllers are part of the Angular MVC scheme that contains client side logic and may issue requests to the server.&lt;br /&gt;
* The server side controllers deal with the models and requests from the client side.&lt;br /&gt;
&lt;br /&gt;
'''Server side:'''&lt;br /&gt;
&lt;br /&gt;
* Find articles.js in the controllers folder. Try to understand what each part does. &lt;br /&gt;
* Find articles.js in /server/routes/middlewares &lt;br /&gt;
You'll see that it requires the articles controller and its methods for querying the database.&lt;br /&gt;
&lt;br /&gt;
The first section requires the articles controller, which defines different methods &lt;br /&gt;
&lt;br /&gt;
For example:     &lt;br /&gt;
app.route('/articles')&lt;br /&gt;
        .get(articles.all)&lt;br /&gt;
tells the server to use a method named &amp;quot;all&amp;quot; in the articles controller when the url is pointed to /articles.&lt;br /&gt;
&lt;br /&gt;
*Go to http://localhost:3000/articles, what do you see? Does it make sense?&lt;br /&gt;
&lt;br /&gt;
'''Client side:''' open up articles.js in /public/articles/controllers&lt;br /&gt;
Compare the functions defined in ArticlesController, can you find the corresponding functions on the server side implementation of articles controller? &lt;br /&gt;
&lt;br /&gt;
Here is a diagram to help you under stand how this works:&lt;br /&gt;
&lt;br /&gt;
[[File:pic]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Views &amp;amp; Routing =&lt;br /&gt;
Let's switch to the public folder where the views reside. &lt;br /&gt;
&lt;br /&gt;
Go to public/articles/views, open up list.html:&lt;br /&gt;
The first line tells the framework that  ArticlesController is responsible for this particular view and when this view is loaded, use find() to initiate data binding.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;section data-ng-controller=&amp;quot;ArticlesController&amp;quot; data-ng-init=&amp;quot;find()&amp;quot;&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Feel free to take a look at what find() does. Make sure you understand that what find() does is actually done by the backend, where a corresponding find() is written (as mentioned above).&lt;br /&gt;
Hopefully you have a better understanding of how these technologies all work together now.&lt;br /&gt;
&lt;br /&gt;
Review the AngularJS section if you have any questions regarding the view data binding.&lt;br /&gt;
&lt;br /&gt;
The view files in articles/views only defines the code for displaying the articles, where does the navigation bar gets defined.&lt;br /&gt;
The answer is in /public/system. &lt;br /&gt;
*The .html files in public/system/views provide a container/layout for the application. &lt;br /&gt;
For example, header.html includes the menu bar (displayed on the top of the page):&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
*&amp;lt;nowiki&amp;gt; &amp;lt;div class=&amp;quot;left pull-left&amp;quot;&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*    &amp;lt;nowiki&amp;gt;    &amp;lt;ul class=&amp;quot;navbar-nav nav&amp;quot;&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*        &amp;lt;nowiki&amp;gt;      &amp;lt;li data-ng-repeat=&amp;quot;item in menus.main&amp;quot; ui-route=&amp;quot;/{{item.link}}&amp;quot; ng-class=&amp;quot;{active: $uiRoute}&amp;quot;&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*            &amp;lt;nowiki&amp;gt;         &amp;lt;a mean-token=&amp;quot;item.link&amp;quot; ui-sref='{{item.link}}'&amp;gt;{{item.title}}&amp;lt;/a&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*        &amp;lt;nowiki&amp;gt;     &amp;lt;/li&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*    &amp;lt;nowiki&amp;gt;   &amp;lt;/ul&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*&amp;lt;nowiki&amp;gt; &amp;lt;/div&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Try changing {{item.title}} inside the &amp;lt;a&amp;gt; &amp;lt;/a&amp;gt;tags to &amp;quot;my articles&amp;quot; see what happens to the page.&lt;br /&gt;
* The ui-sref is &amp;quot;href&amp;quot; in ui-route, an AngularJS plugin, try changing {{item.link}} to #!/myarticles, &lt;br /&gt;
* What happens to the application now? When you click on &amp;quot;my articles&amp;quot;?&lt;br /&gt;
&lt;br /&gt;
The page to articles is no longer served!&lt;br /&gt;
&lt;br /&gt;
But how does the framework know which page to serve given a certain url?  The file that's responsible for this (called routing in web development) is in public/articles/routes&lt;br /&gt;
&lt;br /&gt;
open up articles.js found in this folder and find this line:&lt;br /&gt;
&lt;br /&gt;
            .state('all articles', {&lt;br /&gt;
                url: '/articles',&lt;br /&gt;
                templateUrl: 'public/articles/views/list.html',&lt;br /&gt;
                resolve: {&lt;br /&gt;
                    loggedin: checkLoggedin&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
This is ui-route's way of telling the server what to serve the page specified by the templateUrl when it sees &amp;quot;localhost:3000/#!/phones&amp;quot;. &lt;br /&gt;
The #! is a hash prefix used for MEAN to make ajax calls so make sure to include it when coding your views.&lt;br /&gt;
Now try changing the url to &amp;quot;/myarticles&amp;quot;, save and go back to your app, click on &amp;quot;my articles&amp;quot; now, what happens?&lt;br /&gt;
&lt;br /&gt;
*This is important if you want to customize your navigation bar and links. Just remember that each url needs an entry in the route file, in the format of the example above.&lt;br /&gt;
&lt;br /&gt;
= Practice = &lt;br /&gt;
&lt;br /&gt;
Can you implement a view in your myPackage to display all phones injected in the DB? &lt;br /&gt;
Hint: myPackage has the same file structure as the default app.&lt;/div&gt;</summary>
		<author><name>Vigo</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=1724</id>
		<title>Getting MEAN</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=1724"/>
		<updated>2014-05-11T23:21:48Z</updated>

		<summary type="html">&lt;p&gt;Vigo: /* Installation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Installation ===&lt;br /&gt;
To install MEAN, make sure you already have all of the following components installed and configured correctly.&lt;br /&gt;
1. Node.js (should come with npm) &lt;br /&gt;
To find out if you have node and npm, type node --version and npm --version in your terminal.&lt;br /&gt;
&lt;br /&gt;
you should see something like&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
node --version&lt;br /&gt;
v0.10.25&lt;br /&gt;
npm --version&lt;br /&gt;
1.3.24&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
IF you don't have node.js, install it [here, http://nodejs.org/].&lt;br /&gt;
&lt;br /&gt;
2. Bower&lt;br /&gt;
&lt;br /&gt;
Bower is a web application manager used by MEAN. To install bower, simply type &amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;npm i -g bower&amp;lt;/source&amp;gt; in the terminal.  &lt;br /&gt;
&lt;br /&gt;
3. MongoDB&lt;br /&gt;
To install MongoDB, follow the instructions for your OS [here, http://docs.mongodb.org/manual/installation/].&lt;br /&gt;
&lt;br /&gt;
follow instructions [http://mean.io/#!/docs here] on how to get started. &lt;br /&gt;
* Take a moment and read the rest of the documentations to get familiar with the file structure and idioms.&lt;br /&gt;
&lt;br /&gt;
=== Running the Default App ===&lt;br /&gt;
* Init and run an app. Make sure MongoDB is connected and running (if you run into problems, refer to the section on MongoDB)&lt;br /&gt;
* Explore features of the default Article app (such as logging in, adding/deleting articles).&lt;br /&gt;
&lt;br /&gt;
=== Generating a Package === &lt;br /&gt;
* By now you should know what a package is in MEAN. If you don't, read [http://mean.io/#!/docs this].&lt;br /&gt;
* Try creating a package named myPackage and locate it inside the packages folder&lt;br /&gt;
* Compare the structure of myPackage folder to that of the default app. Make sure you see both '''public''' and  '''server''' folders and their subfolders.&lt;br /&gt;
* Restart your app, make sure you can see a link to the newly created package.&lt;br /&gt;
&lt;br /&gt;
=== A Closer Look at the App ===&lt;br /&gt;
Take a look at the directory where you app resides, you will see two folders '''public''' and  '''server''', which contain code for the client side and server side respectively.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Models =&lt;br /&gt;
&lt;br /&gt;
Open up article.js in /server/models&lt;br /&gt;
&lt;br /&gt;
MEAN is MVC on the client side and the server side.  Since the model is tied to the backend to MongoDB, you will only see the models folder on the server side, which is normal. &lt;br /&gt;
The models are mongoose models that's why we need to require mongoose (what the following line does):&lt;br /&gt;
&lt;br /&gt;
var mongoose = require('mongoose'), Schema = mongoose.Schema;&lt;br /&gt;
&lt;br /&gt;
The following part then defines the schema:&lt;br /&gt;
&lt;br /&gt;
var ArticleSchema = new Schema({&lt;br /&gt;
    created: {&lt;br /&gt;
        type: Date,&lt;br /&gt;
        default: Date.now&lt;br /&gt;
    },&lt;br /&gt;
    title: {&lt;br /&gt;
        type: String,&lt;br /&gt;
        default: '',&lt;br /&gt;
        trim: true&lt;br /&gt;
    },&lt;br /&gt;
    content: {&lt;br /&gt;
        type: String,&lt;br /&gt;
        default: '',&lt;br /&gt;
        trim: true&lt;br /&gt;
    },&lt;br /&gt;
    user: {&lt;br /&gt;
        type: Schema.ObjectId,&lt;br /&gt;
        ref: 'User'&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
The next part is validations, or criteria an object needs to pass before it can be saved to the DB. &lt;br /&gt;
The following code is to make sure that an article has a title:&lt;br /&gt;
&lt;br /&gt;
ArticleSchema.path('title').validate(function(title) {&lt;br /&gt;
    return title.length;&lt;br /&gt;
}, 'Title cannot be blank');&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Finally, Mongoose allows us to define methods to our data objects as well. &lt;br /&gt;
These are called statics. From the Mongoose doc: Schemas not only define the structure of your document and casting of properties, they also define document instance methods, static Model methods, compound indexes and document lifecycle hooks called middleware.&lt;br /&gt;
The following code defines a method called load for the article schema:&lt;br /&gt;
&lt;br /&gt;
ArticleSchema.statics.load = function(id, cb) {&lt;br /&gt;
    this.findOne({&lt;br /&gt;
        _id: id&lt;br /&gt;
    }).populate('user', 'name username').exec(cb);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
If you have trouble understanding what the code does, review the Mongoose [http://mongoosejs.com/docs/index.html quick start] guide.&lt;br /&gt;
&lt;br /&gt;
= Models Practice = &lt;br /&gt;
Define a schema for a model named '''Phone''', name it phone.js and save it in the corresponding folder in 'myPackage' (hint: /packages/myPackage/server/models/)&lt;br /&gt;
A product needs to have the following fields with specific types. Here is an example of a Phone object can be stored in the MongoDB:&lt;br /&gt;
&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;age&amp;quot;: 0, &lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;motorola-xoom-with-wi-fi&amp;quot;, &lt;br /&gt;
        &amp;quot;imageUrl&amp;quot;: &amp;quot;img/phones/motorola-xoom-with-wi-fi.0.jpg&amp;quot;, &lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;Motorola XOOM\u2122 with Wi-Fi&amp;quot;, &lt;br /&gt;
        &amp;quot;snippet&amp;quot;: &amp;quot;The Next, Next Generation\r\n\r\nExperience the future with Motorola XOOM with Wi-Fi, the world's first tablet powered by Android 3.0 (Honeycomb).&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
This is taken from phones.json used by the AngularJS tutorial. If you have gone through the tutorial, you should have realized that instead of using a DB, json files were used to simplify the tutorial.&lt;br /&gt;
Find phones.json in /app/phones in the angular tutorial folder and try importing its content to MongoDB so you can use them in your current MEAN package.&lt;br /&gt;
&lt;br /&gt;
*Run '''mongod''' and connect to mongo shell (mongo --shell), then type &amp;quot;use mean-dev&amp;quot; to switch to database used by mean.&lt;br /&gt;
*Type  mongoimport --db mean-dev --collection phones --type json --file ''&amp;lt;path to phones.json&amp;gt;'' --jsonArray&lt;br /&gt;
*Type show collections to see if phones are added to your database, type coll = db.phones to see the content of the file.&lt;br /&gt;
&lt;br /&gt;
= Controllers =&lt;br /&gt;
&lt;br /&gt;
You'll find a controllers folder on both the server side and the client side.  &lt;br /&gt;
* The client side controllers are part of the Angular MVC scheme that contains client side logic and may issue requests to the server.&lt;br /&gt;
* The server side controllers deal with the models and requests from the client side.&lt;br /&gt;
&lt;br /&gt;
'''Server side:'''&lt;br /&gt;
&lt;br /&gt;
* Find articles.js in the controllers folder. Try to understand what each part does. &lt;br /&gt;
* Find articles.js in /server/routes/middlewares &lt;br /&gt;
You'll see that it requires the articles controller and its methods for querying the database.&lt;br /&gt;
&lt;br /&gt;
The first section requires the articles controller, which defines different methods &lt;br /&gt;
&lt;br /&gt;
For example:     &lt;br /&gt;
app.route('/articles')&lt;br /&gt;
        .get(articles.all)&lt;br /&gt;
tells the server to use a method named &amp;quot;all&amp;quot; in the articles controller when the url is pointed to /articles.&lt;br /&gt;
&lt;br /&gt;
*Go to http://localhost:3000/articles, what do you see? Does it make sense?&lt;br /&gt;
&lt;br /&gt;
'''Client side:''' open up articles.js in /public/articles/controllers&lt;br /&gt;
Compare the functions defined in ArticlesController, can you find the corresponding functions on the server side implementation of articles controller? &lt;br /&gt;
&lt;br /&gt;
Here is a diagram to help you under stand how this works:&lt;br /&gt;
&lt;br /&gt;
[[File:pic]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Views &amp;amp; Routing =&lt;br /&gt;
Let's switch to the public folder where the views reside. &lt;br /&gt;
&lt;br /&gt;
Go to public/articles/views, open up list.html:&lt;br /&gt;
The first line tells the framework that  ArticlesController is responsible for this particular view and when this view is loaded, use find() to initiate data binding.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;section data-ng-controller=&amp;quot;ArticlesController&amp;quot; data-ng-init=&amp;quot;find()&amp;quot;&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Feel free to take a look at what find() does. Make sure you understand that what find() does is actually done by the backend, where a corresponding find() is written (as mentioned above).&lt;br /&gt;
Hopefully you have a better understanding of how these technologies all work together now.&lt;br /&gt;
&lt;br /&gt;
Review the AngularJS section if you have any questions regarding the view data binding.&lt;br /&gt;
&lt;br /&gt;
The view files in articles/views only defines the code for displaying the articles, where does the navigation bar gets defined.&lt;br /&gt;
The answer is in /public/system. &lt;br /&gt;
*The .html files in public/system/views provide a container/layout for the application. &lt;br /&gt;
For example, header.html includes the menu bar (displayed on the top of the page):&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
*&amp;lt;nowiki&amp;gt; &amp;lt;div class=&amp;quot;left pull-left&amp;quot;&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*    &amp;lt;nowiki&amp;gt;    &amp;lt;ul class=&amp;quot;navbar-nav nav&amp;quot;&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*        &amp;lt;nowiki&amp;gt;      &amp;lt;li data-ng-repeat=&amp;quot;item in menus.main&amp;quot; ui-route=&amp;quot;/{{item.link}}&amp;quot; ng-class=&amp;quot;{active: $uiRoute}&amp;quot;&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*            &amp;lt;nowiki&amp;gt;         &amp;lt;a mean-token=&amp;quot;item.link&amp;quot; ui-sref='{{item.link}}'&amp;gt;{{item.title}}&amp;lt;/a&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*        &amp;lt;nowiki&amp;gt;     &amp;lt;/li&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*    &amp;lt;nowiki&amp;gt;   &amp;lt;/ul&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*&amp;lt;nowiki&amp;gt; &amp;lt;/div&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Try changing {{item.title}} inside the &amp;lt;a&amp;gt; &amp;lt;/a&amp;gt;tags to &amp;quot;my articles&amp;quot; see what happens to the page.&lt;br /&gt;
* The ui-sref is &amp;quot;href&amp;quot; in ui-route, an AngularJS plugin, try changing {{item.link}} to #!/myarticles, &lt;br /&gt;
* What happens to the application now? When you click on &amp;quot;my articles&amp;quot;?&lt;br /&gt;
&lt;br /&gt;
The page to articles is no longer served!&lt;br /&gt;
&lt;br /&gt;
But how does the framework know which page to serve given a certain url?  The file that's responsible for this (called routing in web development) is in public/articles/routes&lt;br /&gt;
&lt;br /&gt;
open up articles.js found in this folder and find this line:&lt;br /&gt;
&lt;br /&gt;
            .state('all articles', {&lt;br /&gt;
                url: '/articles',&lt;br /&gt;
                templateUrl: 'public/articles/views/list.html',&lt;br /&gt;
                resolve: {&lt;br /&gt;
                    loggedin: checkLoggedin&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
This is ui-route's way of telling the server what to serve the page specified by the templateUrl when it sees &amp;quot;localhost:3000/#!/phones&amp;quot;. &lt;br /&gt;
The #! is a hash prefix used for MEAN to make ajax calls so make sure to include it when coding your views.&lt;br /&gt;
Now try changing the url to &amp;quot;/myarticles&amp;quot;, save and go back to your app, click on &amp;quot;my articles&amp;quot; now, what happens?&lt;br /&gt;
&lt;br /&gt;
*This is important if you want to customize your navigation bar and links. Just remember that each url needs an entry in the route file, in the format of the example above.&lt;br /&gt;
&lt;br /&gt;
= Practice = &lt;br /&gt;
&lt;br /&gt;
Can you implement a view in your myPackage to display all phones injected in the DB? &lt;br /&gt;
Hint: myPackage has the same file structure as the default app.&lt;/div&gt;</summary>
		<author><name>Vigo</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=1723</id>
		<title>Getting MEAN</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=1723"/>
		<updated>2014-05-11T23:14:39Z</updated>

		<summary type="html">&lt;p&gt;Vigo: /* Installation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Installation ===&lt;br /&gt;
* To install MEAN, make sure you already have all of the following components installed.&lt;br /&gt;
1. Node.js (should come with npm) &lt;br /&gt;
To find out if you have node and npm, type node --version and npm --version in your terminal.&lt;br /&gt;
&lt;br /&gt;
you should see something like&lt;br /&gt;
node --version&lt;br /&gt;
v0.10.25&lt;br /&gt;
npm --version&lt;br /&gt;
1.3.24&lt;br /&gt;
&lt;br /&gt;
IF you don't have node.js, install it [here, http://nodejs.org/].&lt;br /&gt;
&lt;br /&gt;
2. Bower&lt;br /&gt;
&lt;br /&gt;
Bower is a web application manager used by MEAN. To install bower, simply type ''npm i -g bower'' in the terminal.  &lt;br /&gt;
&lt;br /&gt;
3. MongoDB&lt;br /&gt;
To download MongoDB, select the build for your OS [here, http://www.mongodb.org/downloads].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
follow instructions [http://mean.io/#!/docs here] on how to get started. &lt;br /&gt;
* Take a moment and read the rest of the documentations to get familiar with the file structure and idioms.&lt;br /&gt;
&lt;br /&gt;
=== Running the Default App ===&lt;br /&gt;
* Init and run an app. Make sure MongoDB is connected and running (if you run into problems, refer to the section on MongoDB)&lt;br /&gt;
* Explore features of the default Article app (such as logging in, adding/deleting articles).&lt;br /&gt;
&lt;br /&gt;
=== Generating a Package === &lt;br /&gt;
* By now you should know what a package is in MEAN. If you don't, read [http://mean.io/#!/docs this].&lt;br /&gt;
* Try creating a package named myPackage and locate it inside the packages folder&lt;br /&gt;
* Compare the structure of myPackage folder to that of the default app. Make sure you see both '''public''' and  '''server''' folders and their subfolders.&lt;br /&gt;
* Restart your app, make sure you can see a link to the newly created package.&lt;br /&gt;
&lt;br /&gt;
=== A Closer Look at the App ===&lt;br /&gt;
Take a look at the directory where you app resides, you will see two folders '''public''' and  '''server''', which contain code for the client side and server side respectively.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Models =&lt;br /&gt;
&lt;br /&gt;
Open up article.js in /server/models&lt;br /&gt;
&lt;br /&gt;
MEAN is MVC on the client side and the server side.  Since the model is tied to the backend to MongoDB, you will only see the models folder on the server side, which is normal. &lt;br /&gt;
The models are mongoose models that's why we need to require mongoose (what the following line does):&lt;br /&gt;
&lt;br /&gt;
var mongoose = require('mongoose'), Schema = mongoose.Schema;&lt;br /&gt;
&lt;br /&gt;
The following part then defines the schema:&lt;br /&gt;
&lt;br /&gt;
var ArticleSchema = new Schema({&lt;br /&gt;
    created: {&lt;br /&gt;
        type: Date,&lt;br /&gt;
        default: Date.now&lt;br /&gt;
    },&lt;br /&gt;
    title: {&lt;br /&gt;
        type: String,&lt;br /&gt;
        default: '',&lt;br /&gt;
        trim: true&lt;br /&gt;
    },&lt;br /&gt;
    content: {&lt;br /&gt;
        type: String,&lt;br /&gt;
        default: '',&lt;br /&gt;
        trim: true&lt;br /&gt;
    },&lt;br /&gt;
    user: {&lt;br /&gt;
        type: Schema.ObjectId,&lt;br /&gt;
        ref: 'User'&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
The next part is validations, or criteria an object needs to pass before it can be saved to the DB. &lt;br /&gt;
The following code is to make sure that an article has a title:&lt;br /&gt;
&lt;br /&gt;
ArticleSchema.path('title').validate(function(title) {&lt;br /&gt;
    return title.length;&lt;br /&gt;
}, 'Title cannot be blank');&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Finally, Mongoose allows us to define methods to our data objects as well. &lt;br /&gt;
These are called statics. From the Mongoose doc: Schemas not only define the structure of your document and casting of properties, they also define document instance methods, static Model methods, compound indexes and document lifecycle hooks called middleware.&lt;br /&gt;
The following code defines a method called load for the article schema:&lt;br /&gt;
&lt;br /&gt;
ArticleSchema.statics.load = function(id, cb) {&lt;br /&gt;
    this.findOne({&lt;br /&gt;
        _id: id&lt;br /&gt;
    }).populate('user', 'name username').exec(cb);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
If you have trouble understanding what the code does, review the Mongoose [http://mongoosejs.com/docs/index.html quick start] guide.&lt;br /&gt;
&lt;br /&gt;
= Models Practice = &lt;br /&gt;
Define a schema for a model named '''Phone''', name it phone.js and save it in the corresponding folder in 'myPackage' (hint: /packages/myPackage/server/models/)&lt;br /&gt;
A product needs to have the following fields with specific types. Here is an example of a Phone object can be stored in the MongoDB:&lt;br /&gt;
&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;age&amp;quot;: 0, &lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;motorola-xoom-with-wi-fi&amp;quot;, &lt;br /&gt;
        &amp;quot;imageUrl&amp;quot;: &amp;quot;img/phones/motorola-xoom-with-wi-fi.0.jpg&amp;quot;, &lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;Motorola XOOM\u2122 with Wi-Fi&amp;quot;, &lt;br /&gt;
        &amp;quot;snippet&amp;quot;: &amp;quot;The Next, Next Generation\r\n\r\nExperience the future with Motorola XOOM with Wi-Fi, the world's first tablet powered by Android 3.0 (Honeycomb).&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
This is taken from phones.json used by the AngularJS tutorial. If you have gone through the tutorial, you should have realized that instead of using a DB, json files were used to simplify the tutorial.&lt;br /&gt;
Find phones.json in /app/phones in the angular tutorial folder and try importing its content to MongoDB so you can use them in your current MEAN package.&lt;br /&gt;
&lt;br /&gt;
*Run '''mongod''' and connect to mongo shell (mongo --shell), then type &amp;quot;use mean-dev&amp;quot; to switch to database used by mean.&lt;br /&gt;
*Type  mongoimport --db mean-dev --collection phones --type json --file ''&amp;lt;path to phones.json&amp;gt;'' --jsonArray&lt;br /&gt;
*Type show collections to see if phones are added to your database, type coll = db.phones to see the content of the file.&lt;br /&gt;
&lt;br /&gt;
= Controllers =&lt;br /&gt;
&lt;br /&gt;
You'll find a controllers folder on both the server side and the client side.  &lt;br /&gt;
* The client side controllers are part of the Angular MVC scheme that contains client side logic and may issue requests to the server.&lt;br /&gt;
* The server side controllers deal with the models and requests from the client side.&lt;br /&gt;
&lt;br /&gt;
'''Server side:'''&lt;br /&gt;
&lt;br /&gt;
* Find articles.js in the controllers folder. Try to understand what each part does. &lt;br /&gt;
* Find articles.js in /server/routes/middlewares &lt;br /&gt;
You'll see that it requires the articles controller and its methods for querying the database.&lt;br /&gt;
&lt;br /&gt;
The first section requires the articles controller, which defines different methods &lt;br /&gt;
&lt;br /&gt;
For example:     &lt;br /&gt;
app.route('/articles')&lt;br /&gt;
        .get(articles.all)&lt;br /&gt;
tells the server to use a method named &amp;quot;all&amp;quot; in the articles controller when the url is pointed to /articles.&lt;br /&gt;
&lt;br /&gt;
*Go to http://localhost:3000/articles, what do you see? Does it make sense?&lt;br /&gt;
&lt;br /&gt;
'''Client side:''' open up articles.js in /public/articles/controllers&lt;br /&gt;
Compare the functions defined in ArticlesController, can you find the corresponding functions on the server side implementation of articles controller? &lt;br /&gt;
&lt;br /&gt;
Here is a diagram to help you under stand how this works:&lt;br /&gt;
&lt;br /&gt;
[[File:pic]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Views &amp;amp; Routing =&lt;br /&gt;
Let's switch to the public folder where the views reside. &lt;br /&gt;
&lt;br /&gt;
Go to public/articles/views, open up list.html:&lt;br /&gt;
The first line tells the framework that  ArticlesController is responsible for this particular view and when this view is loaded, use find() to initiate data binding.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;section data-ng-controller=&amp;quot;ArticlesController&amp;quot; data-ng-init=&amp;quot;find()&amp;quot;&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Feel free to take a look at what find() does. Make sure you understand that what find() does is actually done by the backend, where a corresponding find() is written (as mentioned above).&lt;br /&gt;
Hopefully you have a better understanding of how these technologies all work together now.&lt;br /&gt;
&lt;br /&gt;
Review the AngularJS section if you have any questions regarding the view data binding.&lt;br /&gt;
&lt;br /&gt;
The view files in articles/views only defines the code for displaying the articles, where does the navigation bar gets defined.&lt;br /&gt;
The answer is in /public/system. &lt;br /&gt;
*The .html files in public/system/views provide a container/layout for the application. &lt;br /&gt;
For example, header.html includes the menu bar (displayed on the top of the page):&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
*&amp;lt;nowiki&amp;gt; &amp;lt;div class=&amp;quot;left pull-left&amp;quot;&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*    &amp;lt;nowiki&amp;gt;    &amp;lt;ul class=&amp;quot;navbar-nav nav&amp;quot;&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*        &amp;lt;nowiki&amp;gt;      &amp;lt;li data-ng-repeat=&amp;quot;item in menus.main&amp;quot; ui-route=&amp;quot;/{{item.link}}&amp;quot; ng-class=&amp;quot;{active: $uiRoute}&amp;quot;&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*            &amp;lt;nowiki&amp;gt;         &amp;lt;a mean-token=&amp;quot;item.link&amp;quot; ui-sref='{{item.link}}'&amp;gt;{{item.title}}&amp;lt;/a&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*        &amp;lt;nowiki&amp;gt;     &amp;lt;/li&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*    &amp;lt;nowiki&amp;gt;   &amp;lt;/ul&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*&amp;lt;nowiki&amp;gt; &amp;lt;/div&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Try changing {{item.title}} inside the &amp;lt;a&amp;gt; &amp;lt;/a&amp;gt;tags to &amp;quot;my articles&amp;quot; see what happens to the page.&lt;br /&gt;
* The ui-sref is &amp;quot;href&amp;quot; in ui-route, an AngularJS plugin, try changing {{item.link}} to #!/myarticles, &lt;br /&gt;
* What happens to the application now? When you click on &amp;quot;my articles&amp;quot;?&lt;br /&gt;
&lt;br /&gt;
The page to articles is no longer served!&lt;br /&gt;
&lt;br /&gt;
But how does the framework know which page to serve given a certain url?  The file that's responsible for this (called routing in web development) is in public/articles/routes&lt;br /&gt;
&lt;br /&gt;
open up articles.js found in this folder and find this line:&lt;br /&gt;
&lt;br /&gt;
            .state('all articles', {&lt;br /&gt;
                url: '/articles',&lt;br /&gt;
                templateUrl: 'public/articles/views/list.html',&lt;br /&gt;
                resolve: {&lt;br /&gt;
                    loggedin: checkLoggedin&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
This is ui-route's way of telling the server what to serve the page specified by the templateUrl when it sees &amp;quot;localhost:3000/#!/phones&amp;quot;. &lt;br /&gt;
The #! is a hash prefix used for MEAN to make ajax calls so make sure to include it when coding your views.&lt;br /&gt;
Now try changing the url to &amp;quot;/myarticles&amp;quot;, save and go back to your app, click on &amp;quot;my articles&amp;quot; now, what happens?&lt;br /&gt;
&lt;br /&gt;
*This is important if you want to customize your navigation bar and links. Just remember that each url needs an entry in the route file, in the format of the example above.&lt;br /&gt;
&lt;br /&gt;
= Practice = &lt;br /&gt;
&lt;br /&gt;
Can you implement a view in your myPackage to display all phones injected in the DB? &lt;br /&gt;
Hint: myPackage has the same file structure as the default app.&lt;/div&gt;</summary>
		<author><name>Vigo</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_9&amp;diff=1722</id>
		<title>Module 9</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_9&amp;diff=1722"/>
		<updated>2014-05-11T23:04:56Z</updated>

		<summary type="html">&lt;p&gt;Vigo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
&lt;br /&gt;
This module introduces MEAN, a fullstack web framework that uses '''M'''ongoDB, '''E'''xpress, '''A'''ngularJS and '''N'''ode.js. &amp;lt;br/&amp;gt;&lt;br /&gt;
You have already learned (some things) about Node.js. In this module, you will be introduced to other three new technologies. Don’t frown yet, the goal of this module is to expose you to the concept of web frameworks and prepare you for the creative project. You are not required to be an expert in all of these technologies, however, it’s important to understand the basics of each and how they work together.&lt;br /&gt;
Follow along the tutorials and complete exercises to learn how things work, and you will be ready to create your own web applications using the MEAN stack very soon!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Reading ==&lt;br /&gt;
&lt;br /&gt;
The following articles on the online class wiki textbook contain information that will help you complete the assignment.&lt;br /&gt;
&lt;br /&gt;
*[[Preparations]]&lt;br /&gt;
*[[Getting MEAN]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignments ==&lt;br /&gt;
&lt;br /&gt;
=== Tutorials ===&lt;br /&gt;
&lt;br /&gt;
Make sure you go through tutorials for both MongoDB and AngularJS, and understand how Express works.&lt;br /&gt;
&lt;br /&gt;
=== Install MEAN ===&lt;br /&gt;
&lt;br /&gt;
Follow the steps and install MEAN on your machine, initialize an app and type grunt in your terminal to start the server (make sure your mongoDB server is connected and running).&lt;br /&gt;
Open up the app in your browser (localhost:3000), and understand what the default app does.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Group Project ==&lt;br /&gt;
* Make an e-commerce site using the MEAN stack.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To start, come up with use cases for your site. Think about what products the site is selling, what the user can do, and how information is stored etc.&lt;br /&gt;
&lt;br /&gt;
You may start with the default MEAN.io app and build on top of it. This way you don't have to implement user authentication. You can also create a MEAN package and start from there. &amp;lt;br/&amp;gt;&lt;br /&gt;
You may use phone models provided by the Angular Phone Catalog app as your products. Review the MongoDB section on how to import JSON data into MongoDB.&lt;br /&gt;
&lt;br /&gt;
==== Tips ====&lt;br /&gt;
&lt;br /&gt;
Review the &amp;quot;Getting MEAN&amp;quot; section to understand the file system so you know how components work with each other.&lt;br /&gt;
Keep in mind that you don't have to understand what every line of code does. Whenever in doubt, refer to the default app.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
We will be grading the following aspects of your work.  There are 100 points total.&lt;br /&gt;
&lt;br /&gt;
# '''Working E-commerce Site (75 points)'''&lt;br /&gt;
#* MEAN installed and set up correctly (10 points).&lt;br /&gt;
#* Models set up correctly (15 points).&lt;br /&gt;
#*: ''including products, orders, and adding payment and shipping address to the user model, you don't have to use phones from the Angular tutorial but you are responsible for populating your products table''&lt;br /&gt;
#* Can display a list of all products, can search, can view details (15 points).&lt;br /&gt;
#* Can add to cart, view cart, cart sustains (data can be accessed across views and shouldn't be lost when page is refreshed) (20 points).&lt;br /&gt;
#* Can check out (5 points).&lt;br /&gt;
#*: ''A user can check out if she has a payment option and a shipping address, on a successful checkout, the cart should be emptied''&lt;br /&gt;
#* Can view orders, delete orders (10 points).&lt;br /&gt;
#*: ''An order is associated to a user and should contain at least four fields: date, total, number of products, shipped to''&lt;br /&gt;
# '''Design and Misc (5 Points):'''&lt;br /&gt;
#* Site is overall user friendly and utilizes Bootstrap (3 points).&lt;br /&gt;
#* App passes JShint with no errors (2 points)&lt;br /&gt;
# '''Creative Portion (20 Points):'''&lt;br /&gt;
#* TBD&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 9]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Vigo</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Preparations&amp;diff=1717</id>
		<title>Preparations</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Preparations&amp;diff=1717"/>
		<updated>2014-04-30T05:25:19Z</updated>

		<summary type="html">&lt;p&gt;Vigo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Full Stack === &lt;br /&gt;
In web development, full stack refers to all the layers involved in building a working web application, including data modeling, server, network, user interface, business logic etc. &lt;br /&gt;
In this module we will focus on the technical layers that are essential for a successful web product, which translates to front end and back end skills. &lt;br /&gt;
&lt;br /&gt;
=== Why MEAN? ===&lt;br /&gt;
&lt;br /&gt;
MEAN is a javascript framework based upon a collection of javascript frameworks.&lt;br /&gt;
It combines the power of all four services and developers can focus on creating awesome apps.&lt;br /&gt;
&lt;br /&gt;
Front end: AngularJS, Bootstrap*&lt;br /&gt;
Back end: Node.js (powered Express)&lt;br /&gt;
Data: MongoDB&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== MongoDB ==&lt;br /&gt;
MongoDB is a leading NoSQL database that uses JSON-style documents with dynamic schemas. &lt;br /&gt;
'''Go through this very short tutorial for MongoDB''' [http://try.mongodb.org here]. This 5 minute tutorial will help you understand how MongoDB works as a noSQL DB service.&lt;br /&gt;
Even though MongoDB is fast, scalable and easy to use, to make it work with the MEAN stack, we need an object modeling service called Mongoose. &amp;lt;br/&amp;gt;&lt;br /&gt;
'''Skim through the Mongoose guide (getting started)''' [http://mongoosejs.com/docs/index.html here] to get a sense of how it works. &lt;br /&gt;
&lt;br /&gt;
==Express==&lt;br /&gt;
&lt;br /&gt;
Express is a minimal and flexible node.js web application framework, providing a robust set of features for building single and multi-page, and hybrid web applications.&lt;br /&gt;
You will not be coding anything for Express in this module (already done by MEAN.io). Make sure you know what it is and why it's used.&lt;br /&gt;
&lt;br /&gt;
==AngularJS==&lt;br /&gt;
Very important to this module. Go through the tutorial [https://docs.angularjs.org/tutorial here].&lt;br /&gt;
&lt;br /&gt;
==Bootstrap==&lt;br /&gt;
&lt;br /&gt;
Bootstrap is the default front end framework for the MEAN.io project. Though you could switch to other frameworks such as Foundation pretty easily.&lt;/div&gt;</summary>
		<author><name>Vigo</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Preparations&amp;diff=1716</id>
		<title>Preparations</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Preparations&amp;diff=1716"/>
		<updated>2014-04-30T05:08:13Z</updated>

		<summary type="html">&lt;p&gt;Vigo: Created page with '=== Fullstack ===     === Why MEAN? ===   == MongoDB == MongoDB is a leading NoSQL database that uses JSON-style documents with dynamic schemas.  '''Go through this very short tu…'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Fullstack === &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Why MEAN? ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== MongoDB ==&lt;br /&gt;
MongoDB is a leading NoSQL database that uses JSON-style documents with dynamic schemas. &lt;br /&gt;
'''Go through this very short tutorial for MongoDB''' [http://try.mongodb.org here]. This 5 minute tutorial will help you understand how MongoDB works as a noSQL DB service.&lt;br /&gt;
Even though MongoDB is fast, scalable and easy to use, to make it work with the MEAN stack, we need an object modeling service called Mongoose. &amp;lt;br/&amp;gt;&lt;br /&gt;
'''Skim through the Mongoose guide (getting started)''' [http://mongoosejs.com/docs/index.html here] to get a sense of how it works. &lt;br /&gt;
&lt;br /&gt;
==Express==&lt;br /&gt;
&lt;br /&gt;
Express is a minimal and flexible node.js web application framework, providing a robust set of features for building single and multi-page, and hybrid web applications.&lt;br /&gt;
&lt;br /&gt;
==AngularJS==&lt;br /&gt;
Go through the tutorial [https://docs.angularjs.org/tutorial here].&lt;br /&gt;
&lt;br /&gt;
==Node.js==&lt;/div&gt;</summary>
		<author><name>Vigo</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_9&amp;diff=1715</id>
		<title>Module 9</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_9&amp;diff=1715"/>
		<updated>2014-04-30T05:05:21Z</updated>

		<summary type="html">&lt;p&gt;Vigo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
&lt;br /&gt;
This module introduces MEAN, a fullstack web framework that uses '''M'''ongoDB, '''E'''xpress, '''A'''ngularJS and '''N'''ode.js. &amp;lt;br/&amp;gt;&lt;br /&gt;
You have already learned (some things) about Node.js. In this module, you will be introduced to other three new technologies. Don’t frown yet, the goal of this module is to introduce you to the concept of web frameworks and prepare you for the creative project. You are not required to be an expert in all of these technologies, however, it’s important to understand the basics of each and how they work together.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Reading ==&lt;br /&gt;
&lt;br /&gt;
The following articles on the online class wiki textbook contain information that will help you complete the assignment.&lt;br /&gt;
&lt;br /&gt;
*[[Preparations]]&lt;br /&gt;
*[[Getting MEAN]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignments ==&lt;br /&gt;
&lt;br /&gt;
=== Tutorials ===&lt;br /&gt;
&lt;br /&gt;
Make sure you go through tutorials for both MongoDB and AngularJS, and understand how Express works.&lt;br /&gt;
&lt;br /&gt;
=== Install MEAN ===&lt;br /&gt;
&lt;br /&gt;
Follow the steps and install MEAN on your machine, initialize an app and type grunt in your terminal to start the server (make sure your mongoDB server is connected and running).&lt;br /&gt;
Open up the app in your browser (localhost:3000), and understand what the default app does.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Group Project ==&lt;br /&gt;
* Make an e-commerce site using the MEAN stack.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To start, come up with use cases for your site. Think about what products the site is selling, what the user can do, and how information is stored etc.&lt;br /&gt;
&lt;br /&gt;
You may start with the default MEAN.io app and build on top of it. This way you don't have to implement user authentication. You can also create a MEAN package and start from there. &amp;lt;br/&amp;gt;&lt;br /&gt;
You may use phone models provided by the Angular Phone Catalog app as your products. Review the MongoDB section on how to import JSON data into MongoDB.&lt;br /&gt;
&lt;br /&gt;
==== Tips ====&lt;br /&gt;
&lt;br /&gt;
Review the &amp;quot;Getting MEAN&amp;quot; section to understand the file system so you know how components work with each other.&lt;br /&gt;
Keep in mind that you don't have to understand what every line of code does. Whenever in doubt, refer to the default app.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
We will be grading the following aspects of your work.  There are 100 points total.&lt;br /&gt;
&lt;br /&gt;
# '''Working E-commerce Site (75 points)'''&lt;br /&gt;
#* MEAN installed and set up correctly (10 points).&lt;br /&gt;
#* Models set up correctly (15 points).&lt;br /&gt;
#*: ''including products, orders, and adding payment and shipping address to the user model, you don't have to use phones from the Angular tutorial but you are responsible for populating your products table''&lt;br /&gt;
#* Can display a list of all products, can search, can view details (15 points).&lt;br /&gt;
#* Can add to cart, view cart, cart sustains (data can be accessed across views and shouldn't be lost when page is refreshed) (20 points).&lt;br /&gt;
#* Can check out (5 points).&lt;br /&gt;
#*: ''A user can check out if she has a payment option and a shipping address, on a successful checkout, the cart should be emptied''&lt;br /&gt;
#* Can view orders, delete orders (10 points).&lt;br /&gt;
#*: ''An order is associated to a user and should contain at least four fields: date, total, number of products, shipped to''&lt;br /&gt;
# '''Design and Misc (5 Points):'''&lt;br /&gt;
#* Site is overall user friendly and utilizes Bootstrap (3 points).&lt;br /&gt;
#* App passes JShint with no errors (2 points)&lt;br /&gt;
# '''Creative Portion (20 Points):'''&lt;br /&gt;
#* TBD&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 9]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Vigo</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_9&amp;diff=1714</id>
		<title>Module 9</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_9&amp;diff=1714"/>
		<updated>2014-04-30T05:03:57Z</updated>

		<summary type="html">&lt;p&gt;Vigo: /* Grading */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
&lt;br /&gt;
This module introduces MEAN, a fullstack web framework that uses '''M'''ongoDB, '''E'''xpress, '''A'''ngularJS and '''N'''ode.js. &amp;lt;br/&amp;gt;&lt;br /&gt;
You have already learned (some things) about Node.js. In this module, you will be introduced to other three new technologies. Don’t frown yet, the goal of this module is to introduce you to the concept of web frameworks and prepare you for the creative project. You are not required to be an expert in all of these technologies, however, it’s important to understand the basics of each and how they work together.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Reading ==&lt;br /&gt;
&lt;br /&gt;
The following articles on the online class wiki textbook contain information that will help you complete the assignment.&lt;br /&gt;
&lt;br /&gt;
*[[Preparations]]&lt;br /&gt;
*[[Getting MEAN]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignments ==&lt;br /&gt;
&lt;br /&gt;
=== Tutorials ===&lt;br /&gt;
&lt;br /&gt;
Make sure you go through tutorials for both MongoDB and AngularJS, and understand how Express works.&lt;br /&gt;
&lt;br /&gt;
=== Install MEAN ===&lt;br /&gt;
&lt;br /&gt;
Follow the steps and install MEAN on your machine, initialize an app and type grunt in your terminal to start the server (make sure your mongoDB server is connected and running).&lt;br /&gt;
Open up the app in your browser (localhost:3000), and understand what the default app does.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Group Project ==&lt;br /&gt;
* Make an e-commerce site using the MEAN stack.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To start, come up with use cases for your site. Think about what products the site is selling, what the user can do, and how information is stored etc.&lt;br /&gt;
&lt;br /&gt;
You may start with the default MEAN.io app and build on top of it. This way you don't have to implement user authentication. You can also create a MEAN package and start from there. &amp;lt;br/&amp;gt;&lt;br /&gt;
You may use phone models provided by the Angular Phone Catalog app as your products. Review the MongoDB section on how to import JSON data into MongoDB.&lt;br /&gt;
&lt;br /&gt;
==== Tips ====&lt;br /&gt;
&lt;br /&gt;
Review the &amp;quot;Getting MEAN&amp;quot; section to understand the file system so you know how components work with each other.&lt;br /&gt;
Keep in mind that you don't have to understand what every line of code does. Whenever in doubt, refer to the default app.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
We will be grading the following aspects of your work.  There are 100 points total.&lt;br /&gt;
&lt;br /&gt;
# '''Working E-commerce Site (75 points)'''&lt;br /&gt;
#* MEAN installed and set up correctly (10 points).&lt;br /&gt;
#* Models set up correctly (15 points).&lt;br /&gt;
#*: ''including products, orders, and adding payment and shipping address to the user model, you don't have to use phones from the Angular tutorial but you are responsible for populating your products table''&lt;br /&gt;
#* Can display a list of all products, can search, can view details (15 points).&lt;br /&gt;
#* Can add to cart, view cart, cart sustains (data can be accessed across views and shouldn't be lost when page is refreshed) (20 points).&lt;br /&gt;
#* Can check out (5 points).&lt;br /&gt;
#*: ''A user can check out if she has a payment option and a shipping address, on a successful checkout, the cart should be emptied''&lt;br /&gt;
#* Can view orders, delete orders (10 points).&lt;br /&gt;
#*: ''An order is associated to a user and should contain at least four fields: date, total, number of products, shipped to''&lt;br /&gt;
&lt;br /&gt;
# '''Design and Misc (5 Points):'''&lt;br /&gt;
#* Site is overall user friendly and utilizes Bootstrap (3 points).&lt;br /&gt;
#* App passes JShint with no errors (2 points)&lt;br /&gt;
&lt;br /&gt;
# '''Creative Portion (20 Points):'''&lt;br /&gt;
#* TBD&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 9]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Vigo</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_9&amp;diff=1713</id>
		<title>Module 9</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_9&amp;diff=1713"/>
		<updated>2014-04-30T05:03:22Z</updated>

		<summary type="html">&lt;p&gt;Vigo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
&lt;br /&gt;
This module introduces MEAN, a fullstack web framework that uses '''M'''ongoDB, '''E'''xpress, '''A'''ngularJS and '''N'''ode.js. &amp;lt;br/&amp;gt;&lt;br /&gt;
You have already learned (some things) about Node.js. In this module, you will be introduced to other three new technologies. Don’t frown yet, the goal of this module is to introduce you to the concept of web frameworks and prepare you for the creative project. You are not required to be an expert in all of these technologies, however, it’s important to understand the basics of each and how they work together.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Reading ==&lt;br /&gt;
&lt;br /&gt;
The following articles on the online class wiki textbook contain information that will help you complete the assignment.&lt;br /&gt;
&lt;br /&gt;
*[[Preparations]]&lt;br /&gt;
*[[Getting MEAN]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignments ==&lt;br /&gt;
&lt;br /&gt;
=== Tutorials ===&lt;br /&gt;
&lt;br /&gt;
Make sure you go through tutorials for both MongoDB and AngularJS, and understand how Express works.&lt;br /&gt;
&lt;br /&gt;
=== Install MEAN ===&lt;br /&gt;
&lt;br /&gt;
Follow the steps and install MEAN on your machine, initialize an app and type grunt in your terminal to start the server (make sure your mongoDB server is connected and running).&lt;br /&gt;
Open up the app in your browser (localhost:3000), and understand what the default app does.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Group Project ==&lt;br /&gt;
* Make an e-commerce site using the MEAN stack.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To start, come up with use cases for your site. Think about what products the site is selling, what the user can do, and how information is stored etc.&lt;br /&gt;
&lt;br /&gt;
You may start with the default MEAN.io app and build on top of it. This way you don't have to implement user authentication. You can also create a MEAN package and start from there. &amp;lt;br/&amp;gt;&lt;br /&gt;
You may use phone models provided by the Angular Phone Catalog app as your products. Review the MongoDB section on how to import JSON data into MongoDB.&lt;br /&gt;
&lt;br /&gt;
==== Tips ====&lt;br /&gt;
&lt;br /&gt;
Review the &amp;quot;Getting MEAN&amp;quot; section to understand the file system so you know how components work with each other.&lt;br /&gt;
Keep in mind that you don't have to understand what every line of code does. Whenever in doubt, refer to the default app.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
We will be grading the following aspects of your work.  There are 100 points total.&lt;br /&gt;
&lt;br /&gt;
# '''Working E-commerce Site (75 points)'''&lt;br /&gt;
#* MEAN installed and set up correctly (10 points).&lt;br /&gt;
#* Models set up correctly (15 points).&lt;br /&gt;
#*: ''including products, orders, and adding payment and shipping address to the user model, you don't have to use phones from the Angular tutorial but you are responsible for populating your products table''&lt;br /&gt;
#* Can display a list of all products, can search, can view details (15 points).&lt;br /&gt;
#* Can add to cart, view cart, cart sustains (data can be accessed across views and shouldn't be lost when page is refreshed) (20 points).&lt;br /&gt;
#* Can check out (5 points).&lt;br /&gt;
#*: ''A user can check out if she has a payment option and a shipping address, on a successful checkout, the cart should be emptied''&lt;br /&gt;
#* Can view orders, delete orders (10 points).&lt;br /&gt;
#*: ''An order is associated to a user and should contain at least four fields: date, total, number of products, shipped to''&lt;br /&gt;
&lt;br /&gt;
# ''Design and Misc (5 Points):'''&lt;br /&gt;
#* Site is overall user friendly and utilizes Bootstrap (3 points).&lt;br /&gt;
#* App passes JShint with no errors (2 points)&lt;br /&gt;
&lt;br /&gt;
# ''Creative Portion (20 Points):'''&lt;br /&gt;
#* TBD&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 9]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Vigo</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=CSE_330_Online_Textbook_-_Table_of_Contents&amp;diff=1712</id>
		<title>CSE 330 Online Textbook - Table of Contents</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=CSE_330_Online_Textbook_-_Table_of_Contents&amp;diff=1712"/>
		<updated>2014-04-30T04:40:57Z</updated>

		<summary type="html">&lt;p&gt;Vigo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;div style=&amp;quot;text-align:center;&amp;quot;&amp;gt;[[File:CSE330Banner.png]]&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &lt;br /&gt;
&amp;lt;div style=&amp;quot;column-width: 300px; -moz-column-width: 300px; -webkit-column-width: 300px;&amp;quot;&amp;gt;&lt;br /&gt;
{{FrontPageModule&lt;br /&gt;
|num=1&lt;br /&gt;
|subject=HTML and CSS Fundamentals&lt;br /&gt;
|links=&lt;br /&gt;
* [[HTML and CSS]]&lt;br /&gt;
* [[HTML Forms]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{FrontPageModule&lt;br /&gt;
|num=2&lt;br /&gt;
|subject=Linux, Apache, and PHP&lt;br /&gt;
|links=&lt;br /&gt;
* [[Linux]]&lt;br /&gt;
* [[Bash]]&lt;br /&gt;
* [[Amazon Web Services]]&lt;br /&gt;
* [[SSH]]&lt;br /&gt;
* [[Apache]]&lt;br /&gt;
* [[PHP]]&lt;br /&gt;
* [[Workflow]]&lt;br /&gt;
* [[Web Application Security, Part 1]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{FrontPageModule&lt;br /&gt;
|num=3&lt;br /&gt;
|subject=SQL Databases&lt;br /&gt;
|links=&lt;br /&gt;
* [[Introduction to MySQL]] (installation)&lt;br /&gt;
* [[MySQL Schema and State]] (queries)&lt;br /&gt;
* [[PHP and MySQL]] (using MySQL from PHP)&lt;br /&gt;
* [[Web Application Security, Part 2]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{FrontPageModule&lt;br /&gt;
|num=4&lt;br /&gt;
|subject=Scripting for Rapid Prototyping&lt;br /&gt;
|links=&lt;br /&gt;
* [[Python]]&lt;br /&gt;
* [[Regular Expressions]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{FrontPageModule&lt;br /&gt;
|num=5&lt;br /&gt;
|subject=Version Control Systems and Web Frameworks&lt;br /&gt;
|links=&lt;br /&gt;
* [[Git]]&lt;br /&gt;
* [[Web Frameworks]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{FrontPageModule&lt;br /&gt;
|num=6&lt;br /&gt;
|subject=JavaScript and APIs&lt;br /&gt;
|links=&lt;br /&gt;
* [[JavaScript]]&lt;br /&gt;
* [[AJAX and JSON]]&lt;br /&gt;
* [[Ext JS]]&lt;br /&gt;
* [[Extensible Calendar]]&lt;br /&gt;
* [[Web Application Security, Part 3]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{FrontPageModule&lt;br /&gt;
|num=7&lt;br /&gt;
|subject=Real-Time Web Applications&lt;br /&gt;
|links=&lt;br /&gt;
* [[Node.JS]]&lt;br /&gt;
* [[Socket.IO]]&lt;br /&gt;
* [[Pong Game]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{FrontPageModule&lt;br /&gt;
|num=8&lt;br /&gt;
|subject=Creative Project&lt;br /&gt;
|links=&lt;br /&gt;
* [[Choosing a Platform]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{FrontPageModule&lt;br /&gt;
|num=9&lt;br /&gt;
|subject=MEAN Stack -- Javascript fullstack for web development&lt;br /&gt;
|links=&lt;br /&gt;
* [[Preparations]]&lt;br /&gt;
* [[Getting MEAN]]&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reference ==&lt;br /&gt;
&lt;br /&gt;
Use this wiki as a starting place for your projects in CSE 330.  However, web development is a large field, so it is impossible for us to document everything you might need to know.  Here are some other places you should look when you need to find something:&lt;br /&gt;
&lt;br /&gt;
* [http://www.webplatform.org/ WebPlatform.org], a community-driven source containing documentation and tutorials for Web technologies&lt;br /&gt;
* [http://www.w3.org/community/webed/wiki/Main_Page The Web Education Community Group Wiki], also sponsored by the W3C.&lt;br /&gt;
* [http://reference.sitepoint.com/html SitePoint], which has a reference page as well as quality articles and tutorials&lt;br /&gt;
* Also take a look at [http://designfestival.com/13-time-saving-tools-for-web-designers/ this list of productivity tools] for web development.&lt;br /&gt;
&lt;br /&gt;
If you can't find what you need in any of these places, try using your favorite search engine.  '''Be wary of sites that come up on search engines.'''  Many HTML reference sites document bad practices and dated techniques.  If you're unsure whether a reference site you find is legitimate, ask a TA.&lt;br /&gt;
&lt;br /&gt;
== Want to Learn More? ==&lt;br /&gt;
&lt;br /&gt;
The limited amount of time in CSE 330 means that we can cover only a subset of the wide range of possible topics in the field of rapid prototyping and web development.  Indeed, the exact topics covered in CSE 330 change from year to year.&lt;br /&gt;
&lt;br /&gt;
Feel free to browse some of the topics that have previously been covered in CSE 330: [[:Category:Former Content|CSE 330 Former Content]]&lt;br /&gt;
&lt;br /&gt;
You should also consider following blogs like [http://www.sitepoint.com/ SitePoint] to keep up-to-date on the latest developments in the field of web development.&lt;br /&gt;
&lt;br /&gt;
== Content License ==&lt;br /&gt;
&lt;br /&gt;
The content of this wiki is copyright (c) 2013, Washington University in St. Louis, Department of Computer Science.  All rights reserved.&lt;br /&gt;
&lt;br /&gt;
=== Modified BSD License ===&lt;br /&gt;
&lt;br /&gt;
Redistribution and use in source and binary forms, with or without modification, by a Third Party who has not completed and is not in the process of completing CSE 330, of the code examples or concepts on this wiki, are permitted, provided that the following conditions are met:&lt;br /&gt;
&lt;br /&gt;
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.&lt;br /&gt;
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.&lt;br /&gt;
* Neither the name of the Washington University School of Engineering and Applied Science nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.&lt;br /&gt;
&lt;br /&gt;
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS TO ALL PARTIES &amp;quot;AS IS&amp;quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.&lt;br /&gt;
&lt;br /&gt;
=== What it Means ===&lt;br /&gt;
&lt;br /&gt;
If you are a student in CSE 330, you may use the code from this wiki freely in your projects without the need for attribution.  If you are not a student in CSE 330, you may use the code from this wiki freely in your projects with attribution.  Either way, the code examples are provided &amp;quot;as is&amp;quot;, without any warranty, and Washington University holds no liability for problems arising from the use of the content in this wiki.&lt;/div&gt;</summary>
		<author><name>Vigo</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=1711</id>
		<title>Getting MEAN</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=1711"/>
		<updated>2014-04-30T04:39:46Z</updated>

		<summary type="html">&lt;p&gt;Vigo: /* Views &amp;amp; Routing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Installation ===&lt;br /&gt;
* To install MEAN, follow instructions [http://mean.io/#!/docs here] on how to get started. &lt;br /&gt;
* Take a moment and read the rest of the documentations to get familiar with the file structure and idioms.&lt;br /&gt;
&lt;br /&gt;
=== Running the Default App ===&lt;br /&gt;
* Init and run an app. Make sure MongoDB is connected and running (if you run into problems, refer to the section on MongoDB)&lt;br /&gt;
* Explore features of the default Article app (such as logging in, adding/deleting articles).&lt;br /&gt;
&lt;br /&gt;
=== Generating a Package === &lt;br /&gt;
* By now you should know what a package is in MEAN. If you don't, read [http://mean.io/#!/docs this].&lt;br /&gt;
* Try creating a package named myPackage and locate it inside the packages folder&lt;br /&gt;
* Compare the structure of myPackage folder to that of the default app. Make sure you see both '''public''' and  '''server''' folders and their subfolders.&lt;br /&gt;
* Restart your app, make sure you can see a link to the newly created package.&lt;br /&gt;
&lt;br /&gt;
=== A Closer Look at the App ===&lt;br /&gt;
Take a look at the directory where you app resides, you will see two folders '''public''' and  '''server''', which contain code for the client side and server side respectively.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Models =&lt;br /&gt;
&lt;br /&gt;
Open up article.js in /server/models&lt;br /&gt;
&lt;br /&gt;
MEAN is MVC on the client side and the server side.  Since the model is tied to the backend to MongoDB, you will only see the models folder on the server side, which is normal. &lt;br /&gt;
The models are mongoose models that's why we need to require mongoose (what the following line does):&lt;br /&gt;
&lt;br /&gt;
var mongoose = require('mongoose'), Schema = mongoose.Schema;&lt;br /&gt;
&lt;br /&gt;
The following part then defines the schema:&lt;br /&gt;
&lt;br /&gt;
var ArticleSchema = new Schema({&lt;br /&gt;
    created: {&lt;br /&gt;
        type: Date,&lt;br /&gt;
        default: Date.now&lt;br /&gt;
    },&lt;br /&gt;
    title: {&lt;br /&gt;
        type: String,&lt;br /&gt;
        default: '',&lt;br /&gt;
        trim: true&lt;br /&gt;
    },&lt;br /&gt;
    content: {&lt;br /&gt;
        type: String,&lt;br /&gt;
        default: '',&lt;br /&gt;
        trim: true&lt;br /&gt;
    },&lt;br /&gt;
    user: {&lt;br /&gt;
        type: Schema.ObjectId,&lt;br /&gt;
        ref: 'User'&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
The next part is validations, or criteria an object needs to pass before it can be saved to the DB. &lt;br /&gt;
The following code is to make sure that an article has a title:&lt;br /&gt;
&lt;br /&gt;
ArticleSchema.path('title').validate(function(title) {&lt;br /&gt;
    return title.length;&lt;br /&gt;
}, 'Title cannot be blank');&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Finally, Mongoose allows us to define methods to our data objects as well. &lt;br /&gt;
These are called statics. From the Mongoose doc: Schemas not only define the structure of your document and casting of properties, they also define document instance methods, static Model methods, compound indexes and document lifecycle hooks called middleware.&lt;br /&gt;
The following code defines a method called load for the article schema:&lt;br /&gt;
&lt;br /&gt;
ArticleSchema.statics.load = function(id, cb) {&lt;br /&gt;
    this.findOne({&lt;br /&gt;
        _id: id&lt;br /&gt;
    }).populate('user', 'name username').exec(cb);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
If you have trouble understanding what the code does, review the Mongoose [http://mongoosejs.com/docs/index.html quick start] guide.&lt;br /&gt;
&lt;br /&gt;
= Models Practice = &lt;br /&gt;
Define a schema for a model named '''Phone''', name it phone.js and save it in the corresponding folder in 'myPackage' (hint: /packages/myPackage/server/models/)&lt;br /&gt;
A product needs to have the following fields with specific types. Here is an example of a Phone object can be stored in the MongoDB:&lt;br /&gt;
&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;age&amp;quot;: 0, &lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;motorola-xoom-with-wi-fi&amp;quot;, &lt;br /&gt;
        &amp;quot;imageUrl&amp;quot;: &amp;quot;img/phones/motorola-xoom-with-wi-fi.0.jpg&amp;quot;, &lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;Motorola XOOM\u2122 with Wi-Fi&amp;quot;, &lt;br /&gt;
        &amp;quot;snippet&amp;quot;: &amp;quot;The Next, Next Generation\r\n\r\nExperience the future with Motorola XOOM with Wi-Fi, the world's first tablet powered by Android 3.0 (Honeycomb).&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
This is taken from phones.json used by the AngularJS tutorial. If you have gone through the tutorial, you should have realized that instead of using a DB, json files were used to simplify the tutorial.&lt;br /&gt;
Find phones.json in /app/phones in the angular tutorial folder and try importing its content to MongoDB so you can use them in your current MEAN package.&lt;br /&gt;
&lt;br /&gt;
*Run '''mongod''' and connect to mongo shell (mongo --shell), then type &amp;quot;use mean-dev&amp;quot; to switch to database used by mean.&lt;br /&gt;
*Type  mongoimport --db mean-dev --collection phones --type json --file ''&amp;lt;path to phones.json&amp;gt;'' --jsonArray&lt;br /&gt;
*Type show collections to see if phones are added to your database, type coll = db.phones to see the content of the file.&lt;br /&gt;
&lt;br /&gt;
= Controllers =&lt;br /&gt;
&lt;br /&gt;
You'll find a controllers folder on both the server side and the client side.  &lt;br /&gt;
* The client side controllers are part of the Angular MVC scheme that contains client side logic and may issue requests to the server.&lt;br /&gt;
* The server side controllers deal with the models and requests from the client side.&lt;br /&gt;
&lt;br /&gt;
'''Server side:'''&lt;br /&gt;
&lt;br /&gt;
* Find articles.js in the controllers folder. Try to understand what each part does. &lt;br /&gt;
* Find articles.js in /server/routes/middlewares &lt;br /&gt;
You'll see that it requires the articles controller and its methods for querying the database.&lt;br /&gt;
&lt;br /&gt;
The first section requires the articles controller, which defines different methods &lt;br /&gt;
&lt;br /&gt;
For example:     &lt;br /&gt;
app.route('/articles')&lt;br /&gt;
        .get(articles.all)&lt;br /&gt;
tells the server to use a method named &amp;quot;all&amp;quot; in the articles controller when the url is pointed to /articles.&lt;br /&gt;
&lt;br /&gt;
*Go to http://localhost:3000/articles, what do you see? Does it make sense?&lt;br /&gt;
&lt;br /&gt;
'''Client side:''' open up articles.js in /public/articles/controllers&lt;br /&gt;
Compare the functions defined in ArticlesController, can you find the corresponding functions on the server side implementation of articles controller? &lt;br /&gt;
&lt;br /&gt;
Here is a diagram to help you under stand how this works:&lt;br /&gt;
&lt;br /&gt;
[[File:pic]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Views &amp;amp; Routing =&lt;br /&gt;
Let's switch to the public folder where the views reside. &lt;br /&gt;
&lt;br /&gt;
Go to public/articles/views, open up list.html:&lt;br /&gt;
The first line tells the framework that  ArticlesController is responsible for this particular view and when this view is loaded, use find() to initiate data binding.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;section data-ng-controller=&amp;quot;ArticlesController&amp;quot; data-ng-init=&amp;quot;find()&amp;quot;&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Feel free to take a look at what find() does. Make sure you understand that what find() does is actually done by the backend, where a corresponding find() is written (as mentioned above).&lt;br /&gt;
Hopefully you have a better understanding of how these technologies all work together now.&lt;br /&gt;
&lt;br /&gt;
Review the AngularJS section if you have any questions regarding the view data binding.&lt;br /&gt;
&lt;br /&gt;
The view files in articles/views only defines the code for displaying the articles, where does the navigation bar gets defined.&lt;br /&gt;
The answer is in /public/system. &lt;br /&gt;
*The .html files in public/system/views provide a container/layout for the application. &lt;br /&gt;
For example, header.html includes the menu bar (displayed on the top of the page):&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
*&amp;lt;nowiki&amp;gt; &amp;lt;div class=&amp;quot;left pull-left&amp;quot;&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*    &amp;lt;nowiki&amp;gt;    &amp;lt;ul class=&amp;quot;navbar-nav nav&amp;quot;&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*        &amp;lt;nowiki&amp;gt;      &amp;lt;li data-ng-repeat=&amp;quot;item in menus.main&amp;quot; ui-route=&amp;quot;/{{item.link}}&amp;quot; ng-class=&amp;quot;{active: $uiRoute}&amp;quot;&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*            &amp;lt;nowiki&amp;gt;         &amp;lt;a mean-token=&amp;quot;item.link&amp;quot; ui-sref='{{item.link}}'&amp;gt;{{item.title}}&amp;lt;/a&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*        &amp;lt;nowiki&amp;gt;     &amp;lt;/li&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*    &amp;lt;nowiki&amp;gt;   &amp;lt;/ul&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
*&amp;lt;nowiki&amp;gt; &amp;lt;/div&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Try changing {{item.title}} inside the &amp;lt;a&amp;gt; &amp;lt;/a&amp;gt;tags to &amp;quot;my articles&amp;quot; see what happens to the page.&lt;br /&gt;
* The ui-sref is &amp;quot;href&amp;quot; in ui-route, an AngularJS plugin, try changing {{item.link}} to #!/myarticles, &lt;br /&gt;
* What happens to the application now? When you click on &amp;quot;my articles&amp;quot;?&lt;br /&gt;
&lt;br /&gt;
The page to articles is no longer served!&lt;br /&gt;
&lt;br /&gt;
But how does the framework know which page to serve given a certain url?  The file that's responsible for this (called routing in web development) is in public/articles/routes&lt;br /&gt;
&lt;br /&gt;
open up articles.js found in this folder and find this line:&lt;br /&gt;
&lt;br /&gt;
            .state('all articles', {&lt;br /&gt;
                url: '/articles',&lt;br /&gt;
                templateUrl: 'public/articles/views/list.html',&lt;br /&gt;
                resolve: {&lt;br /&gt;
                    loggedin: checkLoggedin&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
This is ui-route's way of telling the server what to serve the page specified by the templateUrl when it sees &amp;quot;localhost:3000/#!/phones&amp;quot;. &lt;br /&gt;
The #! is a hash prefix used for MEAN to make ajax calls so make sure to include it when coding your views.&lt;br /&gt;
Now try changing the url to &amp;quot;/myarticles&amp;quot;, save and go back to your app, click on &amp;quot;my articles&amp;quot; now, what happens?&lt;br /&gt;
&lt;br /&gt;
*This is important if you want to customize your navigation bar and links. Just remember that each url needs an entry in the route file, in the format of the example above.&lt;br /&gt;
&lt;br /&gt;
= Practice = &lt;br /&gt;
&lt;br /&gt;
Can you implement a view in your myPackage to display all phones injected in the DB? &lt;br /&gt;
Hint: myPackage has the same file structure as the default app.&lt;/div&gt;</summary>
		<author><name>Vigo</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=1710</id>
		<title>Getting MEAN</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=1710"/>
		<updated>2014-04-30T04:36:15Z</updated>

		<summary type="html">&lt;p&gt;Vigo: /* Views &amp;amp; Routing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Installation ===&lt;br /&gt;
* To install MEAN, follow instructions [http://mean.io/#!/docs here] on how to get started. &lt;br /&gt;
* Take a moment and read the rest of the documentations to get familiar with the file structure and idioms.&lt;br /&gt;
&lt;br /&gt;
=== Running the Default App ===&lt;br /&gt;
* Init and run an app. Make sure MongoDB is connected and running (if you run into problems, refer to the section on MongoDB)&lt;br /&gt;
* Explore features of the default Article app (such as logging in, adding/deleting articles).&lt;br /&gt;
&lt;br /&gt;
=== Generating a Package === &lt;br /&gt;
* By now you should know what a package is in MEAN. If you don't, read [http://mean.io/#!/docs this].&lt;br /&gt;
* Try creating a package named myPackage and locate it inside the packages folder&lt;br /&gt;
* Compare the structure of myPackage folder to that of the default app. Make sure you see both '''public''' and  '''server''' folders and their subfolders.&lt;br /&gt;
* Restart your app, make sure you can see a link to the newly created package.&lt;br /&gt;
&lt;br /&gt;
=== A Closer Look at the App ===&lt;br /&gt;
Take a look at the directory where you app resides, you will see two folders '''public''' and  '''server''', which contain code for the client side and server side respectively.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Models =&lt;br /&gt;
&lt;br /&gt;
Open up article.js in /server/models&lt;br /&gt;
&lt;br /&gt;
MEAN is MVC on the client side and the server side.  Since the model is tied to the backend to MongoDB, you will only see the models folder on the server side, which is normal. &lt;br /&gt;
The models are mongoose models that's why we need to require mongoose (what the following line does):&lt;br /&gt;
&lt;br /&gt;
var mongoose = require('mongoose'), Schema = mongoose.Schema;&lt;br /&gt;
&lt;br /&gt;
The following part then defines the schema:&lt;br /&gt;
&lt;br /&gt;
var ArticleSchema = new Schema({&lt;br /&gt;
    created: {&lt;br /&gt;
        type: Date,&lt;br /&gt;
        default: Date.now&lt;br /&gt;
    },&lt;br /&gt;
    title: {&lt;br /&gt;
        type: String,&lt;br /&gt;
        default: '',&lt;br /&gt;
        trim: true&lt;br /&gt;
    },&lt;br /&gt;
    content: {&lt;br /&gt;
        type: String,&lt;br /&gt;
        default: '',&lt;br /&gt;
        trim: true&lt;br /&gt;
    },&lt;br /&gt;
    user: {&lt;br /&gt;
        type: Schema.ObjectId,&lt;br /&gt;
        ref: 'User'&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
The next part is validations, or criteria an object needs to pass before it can be saved to the DB. &lt;br /&gt;
The following code is to make sure that an article has a title:&lt;br /&gt;
&lt;br /&gt;
ArticleSchema.path('title').validate(function(title) {&lt;br /&gt;
    return title.length;&lt;br /&gt;
}, 'Title cannot be blank');&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Finally, Mongoose allows us to define methods to our data objects as well. &lt;br /&gt;
These are called statics. From the Mongoose doc: Schemas not only define the structure of your document and casting of properties, they also define document instance methods, static Model methods, compound indexes and document lifecycle hooks called middleware.&lt;br /&gt;
The following code defines a method called load for the article schema:&lt;br /&gt;
&lt;br /&gt;
ArticleSchema.statics.load = function(id, cb) {&lt;br /&gt;
    this.findOne({&lt;br /&gt;
        _id: id&lt;br /&gt;
    }).populate('user', 'name username').exec(cb);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
If you have trouble understanding what the code does, review the Mongoose [http://mongoosejs.com/docs/index.html quick start] guide.&lt;br /&gt;
&lt;br /&gt;
= Models Practice = &lt;br /&gt;
Define a schema for a model named '''Phone''', name it phone.js and save it in the corresponding folder in 'myPackage' (hint: /packages/myPackage/server/models/)&lt;br /&gt;
A product needs to have the following fields with specific types. Here is an example of a Phone object can be stored in the MongoDB:&lt;br /&gt;
&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;age&amp;quot;: 0, &lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;motorola-xoom-with-wi-fi&amp;quot;, &lt;br /&gt;
        &amp;quot;imageUrl&amp;quot;: &amp;quot;img/phones/motorola-xoom-with-wi-fi.0.jpg&amp;quot;, &lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;Motorola XOOM\u2122 with Wi-Fi&amp;quot;, &lt;br /&gt;
        &amp;quot;snippet&amp;quot;: &amp;quot;The Next, Next Generation\r\n\r\nExperience the future with Motorola XOOM with Wi-Fi, the world's first tablet powered by Android 3.0 (Honeycomb).&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
This is taken from phones.json used by the AngularJS tutorial. If you have gone through the tutorial, you should have realized that instead of using a DB, json files were used to simplify the tutorial.&lt;br /&gt;
Find phones.json in /app/phones in the angular tutorial folder and try importing its content to MongoDB so you can use them in your current MEAN package.&lt;br /&gt;
&lt;br /&gt;
*Run '''mongod''' and connect to mongo shell (mongo --shell), then type &amp;quot;use mean-dev&amp;quot; to switch to database used by mean.&lt;br /&gt;
*Type  mongoimport --db mean-dev --collection phones --type json --file ''&amp;lt;path to phones.json&amp;gt;'' --jsonArray&lt;br /&gt;
*Type show collections to see if phones are added to your database, type coll = db.phones to see the content of the file.&lt;br /&gt;
&lt;br /&gt;
= Controllers =&lt;br /&gt;
&lt;br /&gt;
You'll find a controllers folder on both the server side and the client side.  &lt;br /&gt;
* The client side controllers are part of the Angular MVC scheme that contains client side logic and may issue requests to the server.&lt;br /&gt;
* The server side controllers deal with the models and requests from the client side.&lt;br /&gt;
&lt;br /&gt;
'''Server side:'''&lt;br /&gt;
&lt;br /&gt;
* Find articles.js in the controllers folder. Try to understand what each part does. &lt;br /&gt;
* Find articles.js in /server/routes/middlewares &lt;br /&gt;
You'll see that it requires the articles controller and its methods for querying the database.&lt;br /&gt;
&lt;br /&gt;
The first section requires the articles controller, which defines different methods &lt;br /&gt;
&lt;br /&gt;
For example:     &lt;br /&gt;
app.route('/articles')&lt;br /&gt;
        .get(articles.all)&lt;br /&gt;
tells the server to use a method named &amp;quot;all&amp;quot; in the articles controller when the url is pointed to /articles.&lt;br /&gt;
&lt;br /&gt;
*Go to http://localhost:3000/articles, what do you see? Does it make sense?&lt;br /&gt;
&lt;br /&gt;
'''Client side:''' open up articles.js in /public/articles/controllers&lt;br /&gt;
Compare the functions defined in ArticlesController, can you find the corresponding functions on the server side implementation of articles controller? &lt;br /&gt;
&lt;br /&gt;
Here is a diagram to help you under stand how this works:&lt;br /&gt;
&lt;br /&gt;
[[File:pic]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Views &amp;amp; Routing =&lt;br /&gt;
Let's switch to the public folder where the views reside. &lt;br /&gt;
&lt;br /&gt;
Go to public/articles/views, open up list.html:&lt;br /&gt;
The first line tells the framework that  ArticlesController is responsible for this particular view and when this view is loaded, use find() to initiate data binding.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;section data-ng-controller=&amp;quot;ArticlesController&amp;quot; data-ng-init=&amp;quot;find()&amp;quot;&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Feel free to take a look at what find() does. Make sure you understand that what find() does is actually done by the backend, where a corresponding find() is written (as mentioned above).&lt;br /&gt;
Hopefully you have a better understanding of how these technologies all work together now.&lt;br /&gt;
&lt;br /&gt;
Review the AngularJS section if you have any questions regarding the view data binding.&lt;br /&gt;
&lt;br /&gt;
The view files in articles/views only defines the code for displaying the articles, where does the navigation bar gets defined.&lt;br /&gt;
The answer is in /public/system. &lt;br /&gt;
*The .html files in public/system/views provide a container/layout for the application. &lt;br /&gt;
For example, header.html includes the menu bar (displayed on the top of the page):&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;nowiki&amp;gt;&lt;br /&gt;
*&amp;lt;div class=&amp;quot;left pull-left&amp;quot;&amp;gt;&lt;br /&gt;
 *   &amp;lt;ul class=&amp;quot;navbar-nav nav&amp;quot;&amp;gt;&lt;br /&gt;
 *     &amp;lt;li data-ng-repeat=&amp;quot;item in menus.main&amp;quot; ui-route=&amp;quot;/{{item.link}}&amp;quot; ng-class=&amp;quot;{active: $uiRoute}&amp;quot;&amp;gt;&lt;br /&gt;
 *         &amp;lt;a mean-token=&amp;quot;item.link&amp;quot; ui-sref='{{item.link}}'&amp;gt;{{item.title}}&amp;lt;/a&amp;gt;&lt;br /&gt;
 *     &amp;lt;/li&amp;gt;&lt;br /&gt;
 *   &amp;lt;/ul&amp;gt;&lt;br /&gt;
 *&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Try changing {{item.title}} inside the &amp;lt;a&amp;gt; &amp;lt;/a&amp;gt;tags to &amp;quot;my articles&amp;quot; see what happens to the page.&lt;br /&gt;
* The ui-sref is &amp;quot;href&amp;quot; in ui-route, an AngularJS plugin, try changing {{item.link}} to #!/myarticles, &lt;br /&gt;
* What happens to the application now? When you click on &amp;quot;my articles&amp;quot;?&lt;br /&gt;
&lt;br /&gt;
The page to articles is no longer served!&lt;br /&gt;
&lt;br /&gt;
But how does the framework know which page to serve given a certain url?  The file that's responsible for this (called routing in web development) is in public/articles/routes&lt;br /&gt;
&lt;br /&gt;
open up articles.js found in this folder and find this line:&lt;br /&gt;
&lt;br /&gt;
            .state('all articles', {&lt;br /&gt;
                url: '/articles',&lt;br /&gt;
                templateUrl: 'public/articles/views/list.html',&lt;br /&gt;
                resolve: {&lt;br /&gt;
                    loggedin: checkLoggedin&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
This is ui-route's way of telling the server what to serve the page specified by the templateUrl when it sees &amp;quot;localhost:3000/#!/phones&amp;quot;. &lt;br /&gt;
The #! is a hash prefix used for MEAN to make ajax calls so make sure to include it when coding your views.&lt;br /&gt;
Now try changing the url to &amp;quot;/myarticles&amp;quot;, save and go back to your app, click on &amp;quot;my articles&amp;quot; now, what happens?&lt;br /&gt;
&lt;br /&gt;
*This is important if you want to customize your navigation bar and links. Just remember that each url needs an entry in the route file, in the format of the example above.&lt;br /&gt;
&lt;br /&gt;
= Practice = &lt;br /&gt;
&lt;br /&gt;
Can you implement a view in your myPackage to display all phones injected in the DB? &lt;br /&gt;
Hint: myPackage has the same file structure as the default app.&lt;/div&gt;</summary>
		<author><name>Vigo</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=1709</id>
		<title>Getting MEAN</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=1709"/>
		<updated>2014-04-30T04:35:07Z</updated>

		<summary type="html">&lt;p&gt;Vigo: /* Views &amp;amp; Routing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Installation ===&lt;br /&gt;
* To install MEAN, follow instructions [http://mean.io/#!/docs here] on how to get started. &lt;br /&gt;
* Take a moment and read the rest of the documentations to get familiar with the file structure and idioms.&lt;br /&gt;
&lt;br /&gt;
=== Running the Default App ===&lt;br /&gt;
* Init and run an app. Make sure MongoDB is connected and running (if you run into problems, refer to the section on MongoDB)&lt;br /&gt;
* Explore features of the default Article app (such as logging in, adding/deleting articles).&lt;br /&gt;
&lt;br /&gt;
=== Generating a Package === &lt;br /&gt;
* By now you should know what a package is in MEAN. If you don't, read [http://mean.io/#!/docs this].&lt;br /&gt;
* Try creating a package named myPackage and locate it inside the packages folder&lt;br /&gt;
* Compare the structure of myPackage folder to that of the default app. Make sure you see both '''public''' and  '''server''' folders and their subfolders.&lt;br /&gt;
* Restart your app, make sure you can see a link to the newly created package.&lt;br /&gt;
&lt;br /&gt;
=== A Closer Look at the App ===&lt;br /&gt;
Take a look at the directory where you app resides, you will see two folders '''public''' and  '''server''', which contain code for the client side and server side respectively.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Models =&lt;br /&gt;
&lt;br /&gt;
Open up article.js in /server/models&lt;br /&gt;
&lt;br /&gt;
MEAN is MVC on the client side and the server side.  Since the model is tied to the backend to MongoDB, you will only see the models folder on the server side, which is normal. &lt;br /&gt;
The models are mongoose models that's why we need to require mongoose (what the following line does):&lt;br /&gt;
&lt;br /&gt;
var mongoose = require('mongoose'), Schema = mongoose.Schema;&lt;br /&gt;
&lt;br /&gt;
The following part then defines the schema:&lt;br /&gt;
&lt;br /&gt;
var ArticleSchema = new Schema({&lt;br /&gt;
    created: {&lt;br /&gt;
        type: Date,&lt;br /&gt;
        default: Date.now&lt;br /&gt;
    },&lt;br /&gt;
    title: {&lt;br /&gt;
        type: String,&lt;br /&gt;
        default: '',&lt;br /&gt;
        trim: true&lt;br /&gt;
    },&lt;br /&gt;
    content: {&lt;br /&gt;
        type: String,&lt;br /&gt;
        default: '',&lt;br /&gt;
        trim: true&lt;br /&gt;
    },&lt;br /&gt;
    user: {&lt;br /&gt;
        type: Schema.ObjectId,&lt;br /&gt;
        ref: 'User'&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
The next part is validations, or criteria an object needs to pass before it can be saved to the DB. &lt;br /&gt;
The following code is to make sure that an article has a title:&lt;br /&gt;
&lt;br /&gt;
ArticleSchema.path('title').validate(function(title) {&lt;br /&gt;
    return title.length;&lt;br /&gt;
}, 'Title cannot be blank');&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Finally, Mongoose allows us to define methods to our data objects as well. &lt;br /&gt;
These are called statics. From the Mongoose doc: Schemas not only define the structure of your document and casting of properties, they also define document instance methods, static Model methods, compound indexes and document lifecycle hooks called middleware.&lt;br /&gt;
The following code defines a method called load for the article schema:&lt;br /&gt;
&lt;br /&gt;
ArticleSchema.statics.load = function(id, cb) {&lt;br /&gt;
    this.findOne({&lt;br /&gt;
        _id: id&lt;br /&gt;
    }).populate('user', 'name username').exec(cb);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
If you have trouble understanding what the code does, review the Mongoose [http://mongoosejs.com/docs/index.html quick start] guide.&lt;br /&gt;
&lt;br /&gt;
= Models Practice = &lt;br /&gt;
Define a schema for a model named '''Phone''', name it phone.js and save it in the corresponding folder in 'myPackage' (hint: /packages/myPackage/server/models/)&lt;br /&gt;
A product needs to have the following fields with specific types. Here is an example of a Phone object can be stored in the MongoDB:&lt;br /&gt;
&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;age&amp;quot;: 0, &lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;motorola-xoom-with-wi-fi&amp;quot;, &lt;br /&gt;
        &amp;quot;imageUrl&amp;quot;: &amp;quot;img/phones/motorola-xoom-with-wi-fi.0.jpg&amp;quot;, &lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;Motorola XOOM\u2122 with Wi-Fi&amp;quot;, &lt;br /&gt;
        &amp;quot;snippet&amp;quot;: &amp;quot;The Next, Next Generation\r\n\r\nExperience the future with Motorola XOOM with Wi-Fi, the world's first tablet powered by Android 3.0 (Honeycomb).&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
This is taken from phones.json used by the AngularJS tutorial. If you have gone through the tutorial, you should have realized that instead of using a DB, json files were used to simplify the tutorial.&lt;br /&gt;
Find phones.json in /app/phones in the angular tutorial folder and try importing its content to MongoDB so you can use them in your current MEAN package.&lt;br /&gt;
&lt;br /&gt;
*Run '''mongod''' and connect to mongo shell (mongo --shell), then type &amp;quot;use mean-dev&amp;quot; to switch to database used by mean.&lt;br /&gt;
*Type  mongoimport --db mean-dev --collection phones --type json --file ''&amp;lt;path to phones.json&amp;gt;'' --jsonArray&lt;br /&gt;
*Type show collections to see if phones are added to your database, type coll = db.phones to see the content of the file.&lt;br /&gt;
&lt;br /&gt;
= Controllers =&lt;br /&gt;
&lt;br /&gt;
You'll find a controllers folder on both the server side and the client side.  &lt;br /&gt;
* The client side controllers are part of the Angular MVC scheme that contains client side logic and may issue requests to the server.&lt;br /&gt;
* The server side controllers deal with the models and requests from the client side.&lt;br /&gt;
&lt;br /&gt;
'''Server side:'''&lt;br /&gt;
&lt;br /&gt;
* Find articles.js in the controllers folder. Try to understand what each part does. &lt;br /&gt;
* Find articles.js in /server/routes/middlewares &lt;br /&gt;
You'll see that it requires the articles controller and its methods for querying the database.&lt;br /&gt;
&lt;br /&gt;
The first section requires the articles controller, which defines different methods &lt;br /&gt;
&lt;br /&gt;
For example:     &lt;br /&gt;
app.route('/articles')&lt;br /&gt;
        .get(articles.all)&lt;br /&gt;
tells the server to use a method named &amp;quot;all&amp;quot; in the articles controller when the url is pointed to /articles.&lt;br /&gt;
&lt;br /&gt;
*Go to http://localhost:3000/articles, what do you see? Does it make sense?&lt;br /&gt;
&lt;br /&gt;
'''Client side:''' open up articles.js in /public/articles/controllers&lt;br /&gt;
Compare the functions defined in ArticlesController, can you find the corresponding functions on the server side implementation of articles controller? &lt;br /&gt;
&lt;br /&gt;
Here is a diagram to help you under stand how this works:&lt;br /&gt;
&lt;br /&gt;
[[File:pic]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Views &amp;amp; Routing =&lt;br /&gt;
Let's switch to the public folder where the views reside. &lt;br /&gt;
&lt;br /&gt;
Go to public/articles/views, open up list.html:&lt;br /&gt;
The first line tells the framework that  ArticlesController is responsible for this particular view and when this view is loaded, use find() to initiate data binding.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;section data-ng-controller=&amp;quot;ArticlesController&amp;quot; data-ng-init=&amp;quot;find()&amp;quot;&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Feel free to take a look at what find() does. Make sure you understand that what find() does is actually done by the backend, where a corresponding find() is written (as mentioned above).&lt;br /&gt;
Hopefully you have a better understanding of how these technologies all work together now.&lt;br /&gt;
&lt;br /&gt;
Review the AngularJS section if you have any questions regarding the view data binding.&lt;br /&gt;
&lt;br /&gt;
The view files in articles/views only defines the code for displaying the articles, where does the navigation bar gets defined.&lt;br /&gt;
The answer is in /public/system. &lt;br /&gt;
*The .html files in public/system/views provide a container/layout for the application. &lt;br /&gt;
For example, header.html includes the menu bar (displayed on the top of the page):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;  &lt;br /&gt;
&amp;lt;div class=&amp;quot;left pull-left&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;ul class=&amp;quot;navbar-nav nav&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;li data-ng-repeat=&amp;quot;item in menus.main&amp;quot; ui-route=&amp;quot;/{{item.link}}&amp;quot; ng-class=&amp;quot;{active: $uiRoute}&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;a mean-token=&amp;quot;item.link&amp;quot; ui-sref='{{item.link}}'&amp;gt;{{item.title}}&amp;lt;/a&amp;gt;&lt;br /&gt;
      &amp;lt;/li&amp;gt;&lt;br /&gt;
    &amp;lt;/ul&amp;gt;&lt;br /&gt;
  &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Try changing {{item.title}} inside the &amp;lt;a&amp;gt; &amp;lt;/a&amp;gt;tags to &amp;quot;my articles&amp;quot; see what happens to the page.&lt;br /&gt;
* The ui-sref is &amp;quot;href&amp;quot; in ui-route, an AngularJS plugin, try changing {{item.link}} to #!/myarticles, &lt;br /&gt;
* What happens to the application now? When you click on &amp;quot;my articles&amp;quot;?&lt;br /&gt;
&lt;br /&gt;
The page to articles is no longer served!&lt;br /&gt;
&lt;br /&gt;
But how does the framework know which page to serve given a certain url?  The file that's responsible for this (called routing in web development) is in public/articles/routes&lt;br /&gt;
&lt;br /&gt;
open up articles.js found in this folder and find this line:&lt;br /&gt;
&lt;br /&gt;
            .state('all articles', {&lt;br /&gt;
                url: '/articles',&lt;br /&gt;
                templateUrl: 'public/articles/views/list.html',&lt;br /&gt;
                resolve: {&lt;br /&gt;
                    loggedin: checkLoggedin&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
This is ui-route's way of telling the server what to serve the page specified by the templateUrl when it sees &amp;quot;localhost:3000/#!/phones&amp;quot;. &lt;br /&gt;
The #! is a hash prefix used for MEAN to make ajax calls so make sure to include it when coding your views.&lt;br /&gt;
Now try changing the url to &amp;quot;/myarticles&amp;quot;, save and go back to your app, click on &amp;quot;my articles&amp;quot; now, what happens?&lt;br /&gt;
&lt;br /&gt;
*This is important if you want to customize your navigation bar and links. Just remember that each url needs an entry in the route file, in the format of the example above.&lt;br /&gt;
&lt;br /&gt;
= Practice = &lt;br /&gt;
&lt;br /&gt;
Can you implement a view in your myPackage to display all phones injected in the DB? &lt;br /&gt;
Hint: myPackage has the same file structure as the default app.&lt;/div&gt;</summary>
		<author><name>Vigo</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=1708</id>
		<title>Getting MEAN</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=1708"/>
		<updated>2014-04-30T04:33:44Z</updated>

		<summary type="html">&lt;p&gt;Vigo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Installation ===&lt;br /&gt;
* To install MEAN, follow instructions [http://mean.io/#!/docs here] on how to get started. &lt;br /&gt;
* Take a moment and read the rest of the documentations to get familiar with the file structure and idioms.&lt;br /&gt;
&lt;br /&gt;
=== Running the Default App ===&lt;br /&gt;
* Init and run an app. Make sure MongoDB is connected and running (if you run into problems, refer to the section on MongoDB)&lt;br /&gt;
* Explore features of the default Article app (such as logging in, adding/deleting articles).&lt;br /&gt;
&lt;br /&gt;
=== Generating a Package === &lt;br /&gt;
* By now you should know what a package is in MEAN. If you don't, read [http://mean.io/#!/docs this].&lt;br /&gt;
* Try creating a package named myPackage and locate it inside the packages folder&lt;br /&gt;
* Compare the structure of myPackage folder to that of the default app. Make sure you see both '''public''' and  '''server''' folders and their subfolders.&lt;br /&gt;
* Restart your app, make sure you can see a link to the newly created package.&lt;br /&gt;
&lt;br /&gt;
=== A Closer Look at the App ===&lt;br /&gt;
Take a look at the directory where you app resides, you will see two folders '''public''' and  '''server''', which contain code for the client side and server side respectively.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Models =&lt;br /&gt;
&lt;br /&gt;
Open up article.js in /server/models&lt;br /&gt;
&lt;br /&gt;
MEAN is MVC on the client side and the server side.  Since the model is tied to the backend to MongoDB, you will only see the models folder on the server side, which is normal. &lt;br /&gt;
The models are mongoose models that's why we need to require mongoose (what the following line does):&lt;br /&gt;
&lt;br /&gt;
var mongoose = require('mongoose'), Schema = mongoose.Schema;&lt;br /&gt;
&lt;br /&gt;
The following part then defines the schema:&lt;br /&gt;
&lt;br /&gt;
var ArticleSchema = new Schema({&lt;br /&gt;
    created: {&lt;br /&gt;
        type: Date,&lt;br /&gt;
        default: Date.now&lt;br /&gt;
    },&lt;br /&gt;
    title: {&lt;br /&gt;
        type: String,&lt;br /&gt;
        default: '',&lt;br /&gt;
        trim: true&lt;br /&gt;
    },&lt;br /&gt;
    content: {&lt;br /&gt;
        type: String,&lt;br /&gt;
        default: '',&lt;br /&gt;
        trim: true&lt;br /&gt;
    },&lt;br /&gt;
    user: {&lt;br /&gt;
        type: Schema.ObjectId,&lt;br /&gt;
        ref: 'User'&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
The next part is validations, or criteria an object needs to pass before it can be saved to the DB. &lt;br /&gt;
The following code is to make sure that an article has a title:&lt;br /&gt;
&lt;br /&gt;
ArticleSchema.path('title').validate(function(title) {&lt;br /&gt;
    return title.length;&lt;br /&gt;
}, 'Title cannot be blank');&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Finally, Mongoose allows us to define methods to our data objects as well. &lt;br /&gt;
These are called statics. From the Mongoose doc: Schemas not only define the structure of your document and casting of properties, they also define document instance methods, static Model methods, compound indexes and document lifecycle hooks called middleware.&lt;br /&gt;
The following code defines a method called load for the article schema:&lt;br /&gt;
&lt;br /&gt;
ArticleSchema.statics.load = function(id, cb) {&lt;br /&gt;
    this.findOne({&lt;br /&gt;
        _id: id&lt;br /&gt;
    }).populate('user', 'name username').exec(cb);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
If you have trouble understanding what the code does, review the Mongoose [http://mongoosejs.com/docs/index.html quick start] guide.&lt;br /&gt;
&lt;br /&gt;
= Models Practice = &lt;br /&gt;
Define a schema for a model named '''Phone''', name it phone.js and save it in the corresponding folder in 'myPackage' (hint: /packages/myPackage/server/models/)&lt;br /&gt;
A product needs to have the following fields with specific types. Here is an example of a Phone object can be stored in the MongoDB:&lt;br /&gt;
&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;age&amp;quot;: 0, &lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;motorola-xoom-with-wi-fi&amp;quot;, &lt;br /&gt;
        &amp;quot;imageUrl&amp;quot;: &amp;quot;img/phones/motorola-xoom-with-wi-fi.0.jpg&amp;quot;, &lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;Motorola XOOM\u2122 with Wi-Fi&amp;quot;, &lt;br /&gt;
        &amp;quot;snippet&amp;quot;: &amp;quot;The Next, Next Generation\r\n\r\nExperience the future with Motorola XOOM with Wi-Fi, the world's first tablet powered by Android 3.0 (Honeycomb).&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
This is taken from phones.json used by the AngularJS tutorial. If you have gone through the tutorial, you should have realized that instead of using a DB, json files were used to simplify the tutorial.&lt;br /&gt;
Find phones.json in /app/phones in the angular tutorial folder and try importing its content to MongoDB so you can use them in your current MEAN package.&lt;br /&gt;
&lt;br /&gt;
*Run '''mongod''' and connect to mongo shell (mongo --shell), then type &amp;quot;use mean-dev&amp;quot; to switch to database used by mean.&lt;br /&gt;
*Type  mongoimport --db mean-dev --collection phones --type json --file ''&amp;lt;path to phones.json&amp;gt;'' --jsonArray&lt;br /&gt;
*Type show collections to see if phones are added to your database, type coll = db.phones to see the content of the file.&lt;br /&gt;
&lt;br /&gt;
= Controllers =&lt;br /&gt;
&lt;br /&gt;
You'll find a controllers folder on both the server side and the client side.  &lt;br /&gt;
* The client side controllers are part of the Angular MVC scheme that contains client side logic and may issue requests to the server.&lt;br /&gt;
* The server side controllers deal with the models and requests from the client side.&lt;br /&gt;
&lt;br /&gt;
'''Server side:'''&lt;br /&gt;
&lt;br /&gt;
* Find articles.js in the controllers folder. Try to understand what each part does. &lt;br /&gt;
* Find articles.js in /server/routes/middlewares &lt;br /&gt;
You'll see that it requires the articles controller and its methods for querying the database.&lt;br /&gt;
&lt;br /&gt;
The first section requires the articles controller, which defines different methods &lt;br /&gt;
&lt;br /&gt;
For example:     &lt;br /&gt;
app.route('/articles')&lt;br /&gt;
        .get(articles.all)&lt;br /&gt;
tells the server to use a method named &amp;quot;all&amp;quot; in the articles controller when the url is pointed to /articles.&lt;br /&gt;
&lt;br /&gt;
*Go to http://localhost:3000/articles, what do you see? Does it make sense?&lt;br /&gt;
&lt;br /&gt;
'''Client side:''' open up articles.js in /public/articles/controllers&lt;br /&gt;
Compare the functions defined in ArticlesController, can you find the corresponding functions on the server side implementation of articles controller? &lt;br /&gt;
&lt;br /&gt;
Here is a diagram to help you under stand how this works:&lt;br /&gt;
&lt;br /&gt;
[[File:pic]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Views &amp;amp; Routing =&lt;br /&gt;
Let's switch to the public folder where the views reside. &lt;br /&gt;
&lt;br /&gt;
Go to public/articles/views, open up list.html:&lt;br /&gt;
The first line tells the framework that  ArticlesController is responsible for this particular view and when this view is loaded, use find() to initiate data binding.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;section data-ng-controller=&amp;quot;ArticlesController&amp;quot; data-ng-init=&amp;quot;find()&amp;quot;&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Feel free to take a look at what find() does. Make sure you understand that what find() does is actually done by the backend, where a corresponding find() is written (as mentioned above).&lt;br /&gt;
Hopefully you have a better understanding of how these technologies all work together now.&lt;br /&gt;
&lt;br /&gt;
Review the AngularJS section if you have any questions regarding the view data binding.&lt;br /&gt;
&lt;br /&gt;
The view files in articles/views only defines the code for displaying the articles, where does the navigation bar gets defined.&lt;br /&gt;
The answer is in /public/system. &lt;br /&gt;
*The .html files in public/system/views provide a container/layout for the application. &lt;br /&gt;
For example, header.html includes the menu bar (displayed on the top of the page):&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;div class=&amp;quot;left pull-left&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;ul class=&amp;quot;navbar-nav nav&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;li data-ng-repeat=&amp;quot;item in menus.main&amp;quot; ui-route=&amp;quot;/{{item.link}}&amp;quot; ng-class=&amp;quot;{active: $uiRoute}&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;a mean-token=&amp;quot;item.link&amp;quot; ui-sref='{{item.link}}'&amp;gt;{{item.title}}&amp;lt;/a&amp;gt;&lt;br /&gt;
      &amp;lt;/li&amp;gt;&lt;br /&gt;
    &amp;lt;/ul&amp;gt;&lt;br /&gt;
  &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Try changing {{item.title}} inside the &amp;lt;a&amp;gt; &amp;lt;/a&amp;gt;tags to &amp;quot;my articles&amp;quot; see what happens to the page.&lt;br /&gt;
* The ui-sref is &amp;quot;href&amp;quot; in ui-route, an AngularJS plugin, try changing {{item.link}} to #!/myarticles, &lt;br /&gt;
* What happens to the application now? When you click on &amp;quot;my articles&amp;quot;?&lt;br /&gt;
&lt;br /&gt;
The page to articles is no longer served!&lt;br /&gt;
&lt;br /&gt;
But how does the framework know which page to serve given a certain url?  The file that's responsible for this (called routing in web development) is in public/articles/routes&lt;br /&gt;
&lt;br /&gt;
open up articles.js found in this folder and find this line:&lt;br /&gt;
&lt;br /&gt;
            .state('all articles', {&lt;br /&gt;
                url: '/articles',&lt;br /&gt;
                templateUrl: 'public/articles/views/list.html',&lt;br /&gt;
                resolve: {&lt;br /&gt;
                    loggedin: checkLoggedin&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
This is ui-route's way of telling the server what to serve the page specified by the templateUrl when it sees &amp;quot;localhost:3000/#!/phones&amp;quot;. &lt;br /&gt;
The #! is a hash prefix used for MEAN to make ajax calls so make sure to include it when coding your views.&lt;br /&gt;
Now try changing the url to &amp;quot;/myarticles&amp;quot;, save and go back to your app, click on &amp;quot;my articles&amp;quot; now, what happens?&lt;br /&gt;
&lt;br /&gt;
*This is important if you want to customize your navigation bar and links. Just remember that each url needs an entry in the route file, in the format of the example above.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Practice = &lt;br /&gt;
&lt;br /&gt;
Can you implement a view in your myPackage to display all phones injected in the DB? &lt;br /&gt;
Hint: myPackage has the same file structure as the default app.&lt;/div&gt;</summary>
		<author><name>Vigo</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=1707</id>
		<title>Getting MEAN</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=1707"/>
		<updated>2014-04-30T04:20:11Z</updated>

		<summary type="html">&lt;p&gt;Vigo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Installation ===&lt;br /&gt;
* To install MEAN, follow instructions [http://mean.io/#!/docs here] on how to get started. &lt;br /&gt;
* Take a moment and read the rest of the documentations to get familiar with the file structure and idioms.&lt;br /&gt;
&lt;br /&gt;
=== Running the Default App ===&lt;br /&gt;
* Init and run an app. Make sure MongoDB is connected and running (if you run into problems, refer to the section on MongoDB)&lt;br /&gt;
* Explore features of the default Article app (such as logging in, adding/deleting articles).&lt;br /&gt;
&lt;br /&gt;
=== Generating a Package === &lt;br /&gt;
* By now you should know what a package is in MEAN. If you don't, read [http://mean.io/#!/docs this].&lt;br /&gt;
* Try creating a package named myPackage and locate it inside the packages folder&lt;br /&gt;
* Compare the structure of myPackage folder to that of the default app. Make sure you see both '''public''' and  '''server''' folders and their subfolders.&lt;br /&gt;
* Restart your app, make sure you can see a link to the newly created package.&lt;br /&gt;
&lt;br /&gt;
== A Closer Look at the App ==&lt;br /&gt;
Take a look at the directory where you app resides, you will see two folders '''public''' and  '''server''', which contain code for the client side and server side respectively.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Models =&lt;br /&gt;
&lt;br /&gt;
Open up article.js in /server/models&lt;br /&gt;
&lt;br /&gt;
MEAN is MVC on the client side and the server side.  Since the model is tied to the backend to MongoDB, you will only see the models folder on the server side, which is normal. &lt;br /&gt;
The models are mongoose models that's why we need to require mongoose (what the following line does):&lt;br /&gt;
&lt;br /&gt;
var mongoose = require('mongoose'), Schema = mongoose.Schema;&lt;br /&gt;
&lt;br /&gt;
The following part then defines the schema:&lt;br /&gt;
&lt;br /&gt;
var ArticleSchema = new Schema({&lt;br /&gt;
    created: {&lt;br /&gt;
        type: Date,&lt;br /&gt;
        default: Date.now&lt;br /&gt;
    },&lt;br /&gt;
    title: {&lt;br /&gt;
        type: String,&lt;br /&gt;
        default: '',&lt;br /&gt;
        trim: true&lt;br /&gt;
    },&lt;br /&gt;
    content: {&lt;br /&gt;
        type: String,&lt;br /&gt;
        default: '',&lt;br /&gt;
        trim: true&lt;br /&gt;
    },&lt;br /&gt;
    user: {&lt;br /&gt;
        type: Schema.ObjectId,&lt;br /&gt;
        ref: 'User'&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
The next part is validations, or criteria an object needs to pass before it can be saved to the DB. &lt;br /&gt;
The following code is to make sure that an article has a title:&lt;br /&gt;
&lt;br /&gt;
ArticleSchema.path('title').validate(function(title) {&lt;br /&gt;
    return title.length;&lt;br /&gt;
}, 'Title cannot be blank');&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Finally, Mongoose allows us to define methods to our data objects as well. &lt;br /&gt;
These are called statics. From the Mongoose doc: Schemas not only define the structure of your document and casting of properties, they also define document instance methods, static Model methods, compound indexes and document lifecycle hooks called middleware.&lt;br /&gt;
The following code defines a method called load for the article schema:&lt;br /&gt;
&lt;br /&gt;
ArticleSchema.statics.load = function(id, cb) {&lt;br /&gt;
    this.findOne({&lt;br /&gt;
        _id: id&lt;br /&gt;
    }).populate('user', 'name username').exec(cb);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
If you have trouble understanding what the code does, review the Mongoose [http://mongoosejs.com/docs/index.html quick start] guide.&lt;br /&gt;
&lt;br /&gt;
= Practice = &lt;br /&gt;
Define a schema for a model named '''Phone''', name it phone.js and save it in the corresponding folder in 'myPackage' (hint: /packages/myPackage/server/models/)&lt;br /&gt;
A product needs to have the following fields with specific types. Here is an example of a Phone object can be stored in the MongoDB:&lt;br /&gt;
&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;age&amp;quot;: 0, &lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;motorola-xoom-with-wi-fi&amp;quot;, &lt;br /&gt;
        &amp;quot;imageUrl&amp;quot;: &amp;quot;img/phones/motorola-xoom-with-wi-fi.0.jpg&amp;quot;, &lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;Motorola XOOM\u2122 with Wi-Fi&amp;quot;, &lt;br /&gt;
        &amp;quot;snippet&amp;quot;: &amp;quot;The Next, Next Generation\r\n\r\nExperience the future with Motorola XOOM with Wi-Fi, the world's first tablet powered by Android 3.0 (Honeycomb).&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
This is taken from phones.json used by the AngularJS tutorial. If you have gone through the tutorial, you should have realized that instead of using a DB, json files were used to simplify the tutorial.&lt;br /&gt;
Find phones.json in /app/phones in the angular tutorial folder and try importing its content to MongoDB so you can use them in your current MEAN package.&lt;br /&gt;
&lt;br /&gt;
*Run '''mongod''' and connect to mongo shell (mongo --shell), then type &amp;quot;use mean-dev&amp;quot; to switch to database used by mean.&lt;br /&gt;
*Type  mongoimport --db mean-dev --collection phones --type json --file ''&amp;lt;path to phones.json&amp;gt;'' --jsonArray&lt;br /&gt;
*Type show collections to see if phones are added to your database, type coll = db.phones to see the content of the file.&lt;br /&gt;
&lt;br /&gt;
= Controllers =&lt;br /&gt;
&lt;br /&gt;
You'll find a controllers folder on both the server side and the client side.  &lt;br /&gt;
* The client side controllers are part of the Angular MVC scheme that contains client side logic and may issue requests to the server.&lt;br /&gt;
* The server side controllers deal with the models and requests from the client side.&lt;br /&gt;
&lt;br /&gt;
'''Server side:'''&lt;br /&gt;
&lt;br /&gt;
* Find articles.js in the controllers folder. Try to understand what each part does. &lt;br /&gt;
* Find articles.js in /server/routes/middlewares &lt;br /&gt;
You'll see that it requires the articles controller and its methods for querying the database.&lt;br /&gt;
&lt;br /&gt;
The first section requires the articles controller, which defines different methods &lt;br /&gt;
&lt;br /&gt;
For example:     &lt;br /&gt;
app.route('/articles')&lt;br /&gt;
        .get(articles.all)&lt;br /&gt;
tells the server to use a method named &amp;quot;all&amp;quot; in the articles controller when the url is pointed to /articles.&lt;br /&gt;
&lt;br /&gt;
*Go to http://localhost:3000/articles, what do you see? Does it make sense?&lt;br /&gt;
&lt;br /&gt;
'''Client side:''' open up articles.js in /public/articles/controllers&lt;br /&gt;
Compare the functions defined in ArticlesController, can you find the corresponding functions on the server side implementation of articles controller? &lt;br /&gt;
&lt;br /&gt;
Here is a diagram to help you under stand how this works:&lt;br /&gt;
&lt;br /&gt;
[[File:pic]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Views &amp;amp; Routing ==&lt;br /&gt;
Let's switch to the public folder where the views reside. &lt;br /&gt;
&lt;br /&gt;
Go to public/articles/views, open up list.html:&lt;br /&gt;
The first line tells the framework that  ArticlesController is responsible for this particular view and when this view is loaded, use find() to initiate data binding.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;section data-ng-controller=&amp;quot;ArticlesController&amp;quot; data-ng-init=&amp;quot;find()&amp;quot;&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Feel free to take a look at what find() does. Make sure you understand that what find() does is actually done by the backend, where a corresponding find() is written (as mentioned above).&lt;br /&gt;
Hopefully you have a better understanding of how these technologies all work together now.&lt;br /&gt;
&lt;br /&gt;
Review the AngularJS section if you have any questions regarding the view data binding.&lt;br /&gt;
&lt;br /&gt;
The view files in articles/views only defines the code for displaying the articles, where does the navigation bar gets defined.&lt;br /&gt;
The answer is in /public/system. &lt;br /&gt;
*The .html files in public/system/views provide a container/layout for the application. &lt;br /&gt;
For example, header.html includes the menu bar (displayed on the top of the page):&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;div class=&amp;quot;left pull-left&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;ul class=&amp;quot;navbar-nav nav&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;li data-ng-repeat=&amp;quot;item in menus.main&amp;quot; ui-route=&amp;quot;/{{item.link}}&amp;quot; ng-class=&amp;quot;{active: $uiRoute}&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;a mean-token=&amp;quot;item.link&amp;quot; ui-sref='{{item.link}}'&amp;gt;{{item.title}}&amp;lt;/a&amp;gt;&lt;br /&gt;
      &amp;lt;/li&amp;gt;&lt;br /&gt;
    &amp;lt;/ul&amp;gt;&lt;br /&gt;
  &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Try changing {{item.title}} inside the &amp;lt;a&amp;gt; &amp;lt;/a&amp;gt;tags to &amp;quot;my articles&amp;quot; see what happens to the page.&lt;br /&gt;
* The ui-sref is &amp;quot;href&amp;quot; in ui-route, an AngularJS plugin, try changing {{item.link}} to #!/newroute, &lt;br /&gt;
* What happens to the application now? When you click on &amp;quot;my articles&amp;quot;?&lt;br /&gt;
&lt;br /&gt;
The page to articles is no longer served!&lt;br /&gt;
&lt;br /&gt;
But how does the framework know which page to serve given a certain url?  The file that's responsible for this (called routing in web development) is in public/articles/routes&lt;br /&gt;
&lt;br /&gt;
open up articles.js found in this folder and find this line:&lt;br /&gt;
&lt;br /&gt;
            .state('all phones', {&lt;br /&gt;
                url: '/phones',&lt;br /&gt;
                templateUrl: 'public/articles/views/list.html',&lt;br /&gt;
                resolve: {&lt;br /&gt;
                    loggedin: checkLoggedin&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
This is ui-route's &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Packages === &lt;br /&gt;
* Create a package and locate it. Compare the file structure&lt;br /&gt;
Once you init and run an app,&lt;/div&gt;</summary>
		<author><name>Vigo</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=1706</id>
		<title>Getting MEAN</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=1706"/>
		<updated>2014-04-30T03:57:21Z</updated>

		<summary type="html">&lt;p&gt;Vigo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Installation ===&lt;br /&gt;
* To install MEAN, follow instructions [http://mean.io/#!/docs here] on how to get started. &lt;br /&gt;
* Take a moment and read the rest of the documentations to get familiar with the file structure and idioms.&lt;br /&gt;
&lt;br /&gt;
=== Running the Default App ===&lt;br /&gt;
* Init and run an app. Make sure MongoDB is connected and running (if you run into problems, refer to the section on MongoDB)&lt;br /&gt;
* Explore features of the default Article app (such as logging in, adding/deleting articles).&lt;br /&gt;
&lt;br /&gt;
=== Generating a Package === &lt;br /&gt;
* By now you should know what a package is in MEAN. If you don't, read [http://mean.io/#!/docs this].&lt;br /&gt;
* Try creating a package named myPackage and locate it inside the packages folder&lt;br /&gt;
* Compare the structure of myPackage folder to that of the default app. Make sure you see both '''public''' and  '''server''' folders and their subfolders.&lt;br /&gt;
* Restart your app, make sure you can see a link to the newly created package.&lt;br /&gt;
&lt;br /&gt;
== A Closer Look at the App ==&lt;br /&gt;
Take a look at the directory where you app resides, you will see two folders '''public''' and  '''server''', which contain code for the client side and server side respectively.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Models =&lt;br /&gt;
&lt;br /&gt;
Open up article.js in /server/models&lt;br /&gt;
&lt;br /&gt;
MEAN is MVC on the client side and the server side.  Since the model is tied to the backend to MongoDB, you will only see the models folder on the server side, which is normal. &lt;br /&gt;
The models are mongoose models that's why we need to require mongoose (what the following line does):&lt;br /&gt;
&lt;br /&gt;
var mongoose = require('mongoose'), Schema = mongoose.Schema;&lt;br /&gt;
&lt;br /&gt;
The following part then defines the schema:&lt;br /&gt;
&lt;br /&gt;
var ArticleSchema = new Schema({&lt;br /&gt;
    created: {&lt;br /&gt;
        type: Date,&lt;br /&gt;
        default: Date.now&lt;br /&gt;
    },&lt;br /&gt;
    title: {&lt;br /&gt;
        type: String,&lt;br /&gt;
        default: '',&lt;br /&gt;
        trim: true&lt;br /&gt;
    },&lt;br /&gt;
    content: {&lt;br /&gt;
        type: String,&lt;br /&gt;
        default: '',&lt;br /&gt;
        trim: true&lt;br /&gt;
    },&lt;br /&gt;
    user: {&lt;br /&gt;
        type: Schema.ObjectId,&lt;br /&gt;
        ref: 'User'&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
The next part is validations, or criteria an object needs to pass before it can be saved to the DB. &lt;br /&gt;
The following code is to make sure that an article has a title:&lt;br /&gt;
&lt;br /&gt;
ArticleSchema.path('title').validate(function(title) {&lt;br /&gt;
    return title.length;&lt;br /&gt;
}, 'Title cannot be blank');&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Finally, Mongoose allows us to define methods to our data objects as well. &lt;br /&gt;
These are called statics. From the Mongoose doc: Schemas not only define the structure of your document and casting of properties, they also define document instance methods, static Model methods, compound indexes and document lifecycle hooks called middleware.&lt;br /&gt;
The following code defines a method called load for the article schema:&lt;br /&gt;
&lt;br /&gt;
ArticleSchema.statics.load = function(id, cb) {&lt;br /&gt;
    this.findOne({&lt;br /&gt;
        _id: id&lt;br /&gt;
    }).populate('user', 'name username').exec(cb);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
If you have trouble understanding what the code does, review the Mongoose [http://mongoosejs.com/docs/index.html quick start] guide.&lt;br /&gt;
&lt;br /&gt;
= Practice = &lt;br /&gt;
Define a schema for a model named '''Phone''', name it phone.js and save it in the corresponding folder in 'myPackage' (hint: /packages/myPackage/server/models/)&lt;br /&gt;
A product needs to have the following fields with specific types. Here is an example of a Phone object can be stored in the MongoDB:&lt;br /&gt;
&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;age&amp;quot;: 0, &lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;motorola-xoom-with-wi-fi&amp;quot;, &lt;br /&gt;
        &amp;quot;imageUrl&amp;quot;: &amp;quot;img/phones/motorola-xoom-with-wi-fi.0.jpg&amp;quot;, &lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;Motorola XOOM\u2122 with Wi-Fi&amp;quot;, &lt;br /&gt;
        &amp;quot;snippet&amp;quot;: &amp;quot;The Next, Next Generation\r\n\r\nExperience the future with Motorola XOOM with Wi-Fi, the world's first tablet powered by Android 3.0 (Honeycomb).&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
This is taken from phones.json used by the AngularJS tutorial. If you have gone through the tutorial, you should have realized that instead of using a DB, json files were used to simplify the tutorial.&lt;br /&gt;
Find phones.json in /app/phones in the angular tutorial folder and try importing its content to MongoDB so you can use them in your current MEAN package.&lt;br /&gt;
&lt;br /&gt;
*Run '''mongod''' and connect to mongo shell (mongo --shell), then type &amp;quot;use mean-dev&amp;quot; to switch to database used by mean.&lt;br /&gt;
*Type  mongoimport --db mean-dev --collection phones --type json --file ''&amp;lt;path to phones.json&amp;gt;'' --jsonArray&lt;br /&gt;
*Type show collections to see if phones are added to your database, type coll = db.phones to see the content of the file.&lt;br /&gt;
&lt;br /&gt;
= Controllers =&lt;br /&gt;
&lt;br /&gt;
You'll find a controllers folder on both the server side and the client side.  &lt;br /&gt;
* The client side controllers are part of the Angular MVC scheme that contains client side logic and may issue requests to the server.&lt;br /&gt;
* The server side controllers deal with the models and requests from the client side.&lt;br /&gt;
&lt;br /&gt;
'''Server side:'''&lt;br /&gt;
&lt;br /&gt;
* Find articles.js in the controllers folder. Try to understand what each part does. &lt;br /&gt;
* Find articles.js in /server/routes/middlewares &lt;br /&gt;
You'll see that it requires the articles controller and its methods for querying the database.&lt;br /&gt;
&lt;br /&gt;
The first section requires the articles controller, which defines different methods &lt;br /&gt;
&lt;br /&gt;
For example:     &lt;br /&gt;
app.route('/articles')&lt;br /&gt;
        .get(articles.all)&lt;br /&gt;
tells the server to use a method named &amp;quot;all&amp;quot; in the articles controller when the url is pointed to /articles.&lt;br /&gt;
&lt;br /&gt;
*Go to http://localhost:3000/articles, what do you see? Does it make sense?&lt;br /&gt;
&lt;br /&gt;
'''Client side:''' open up articles.js in /public/articles/controllers&lt;br /&gt;
Compare the functions defined in ArticlesController, can you find the corresponding functions on the server side implementation of articles controller? &lt;br /&gt;
&lt;br /&gt;
Here is a diagram to help you under stand how this works:&lt;br /&gt;
&lt;br /&gt;
[[File:pic]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Views &amp;amp; Routing == &lt;br /&gt;
Let's switch to the public folder where the views reside. &lt;br /&gt;
First, go to &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Go to public/articles/views, open up list.html:&lt;br /&gt;
The first line tells the framework that  ArticlesController is responsible for this particular view and when this view is loaded, use find() to initiate data binding.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;section data-ng-controller=&amp;quot;ArticlesController&amp;quot; data-ng-init=&amp;quot;find()&amp;quot;&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Feel free to take a look at what find() does. Make sure you understand that what find() does is actually done by the backend, where a corresponding find() is written (as mentioned above).&lt;br /&gt;
Hopefully you have a better understanding of how these technologies all work together now.&lt;br /&gt;
&lt;br /&gt;
Review the AngularJS section if you have any questions regarding the view data binding &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The .html files in public/system/views provide a container &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Packages === &lt;br /&gt;
* Create a package and locate it. Compare the file structure&lt;br /&gt;
Once you init and run an app,&lt;/div&gt;</summary>
		<author><name>Vigo</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=1705</id>
		<title>Getting MEAN</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=1705"/>
		<updated>2014-04-30T03:12:46Z</updated>

		<summary type="html">&lt;p&gt;Vigo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Installation ===&lt;br /&gt;
* To install MEAN, follow instructions [http://mean.io/#!/docs here] on how to get started. &lt;br /&gt;
* Take a moment and read the rest of the documentations to get familiar with the file structure and idioms.&lt;br /&gt;
&lt;br /&gt;
=== Running the Default App ===&lt;br /&gt;
* Init and run an app. Make sure MongoDB is connected and running (if you run into problems, refer to the section on MongoDB)&lt;br /&gt;
* Explore features of the default Article app (such as logging in, adding/deleting articles).&lt;br /&gt;
&lt;br /&gt;
=== Generating a Package === &lt;br /&gt;
* By now you should know what a package is in MEAN. If you don't, read [http://mean.io/#!/docs this].&lt;br /&gt;
* Try creating a package named myPackage and locate it inside the packages folder&lt;br /&gt;
* Compare the structure of myPackage folder to that of the default app. Make sure you see both '''public''' and  '''server''' folders and their subfolders.&lt;br /&gt;
* Restart your app, make sure you can see a link to the newly created package.&lt;br /&gt;
&lt;br /&gt;
=== A Closer Look at the App ===&lt;br /&gt;
Take a look at the directory where you app resides, you will see two folders '''public''' and  '''server''', which contain code for the client side and server side respectively.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Models ==&lt;br /&gt;
&lt;br /&gt;
Open up article.js in /server/models&lt;br /&gt;
&lt;br /&gt;
MEAN is MVC on the client side and the server side. Its models are mongoose models that's why we need to require mongoose (what the following line does):&lt;br /&gt;
&lt;br /&gt;
var mongoose = require('mongoose'), Schema = mongoose.Schema;&lt;br /&gt;
&lt;br /&gt;
The following part defines the schema:&lt;br /&gt;
&lt;br /&gt;
var ArticleSchema = new Schema({&lt;br /&gt;
    created: {&lt;br /&gt;
        type: Date,&lt;br /&gt;
        default: Date.now&lt;br /&gt;
    },&lt;br /&gt;
    title: {&lt;br /&gt;
        type: String,&lt;br /&gt;
        default: '',&lt;br /&gt;
        trim: true&lt;br /&gt;
    },&lt;br /&gt;
    content: {&lt;br /&gt;
        type: String,&lt;br /&gt;
        default: '',&lt;br /&gt;
        trim: true&lt;br /&gt;
    },&lt;br /&gt;
    user: {&lt;br /&gt;
        type: Schema.ObjectId,&lt;br /&gt;
        ref: 'User'&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
The next part is validations, or criteria an object needs to pass before it can be saved to the DB. &lt;br /&gt;
The following code is to make sure that an article has a title:&lt;br /&gt;
&lt;br /&gt;
ArticleSchema.path('title').validate(function(title) {&lt;br /&gt;
    return title.length;&lt;br /&gt;
}, 'Title cannot be blank');&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Finally, Mongoose allows us to define methods to our data objects as well. &lt;br /&gt;
These are called statics. From the Mongoose doc: Schemas not only define the structure of your document and casting of properties, they also define document instance methods, static Model methods, compound indexes and document lifecycle hooks called middleware.&lt;br /&gt;
The following code defines a method called load for the article schema:&lt;br /&gt;
&lt;br /&gt;
ArticleSchema.statics.load = function(id, cb) {&lt;br /&gt;
    this.findOne({&lt;br /&gt;
        _id: id&lt;br /&gt;
    }).populate('user', 'name username').exec(cb);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
If you have trouble understanding what the code does, review the Mongoose [http://mongoosejs.com/docs/index.html quick start] guide.&lt;br /&gt;
&lt;br /&gt;
= Practice = &lt;br /&gt;
Define a schema for a model named '''Phone''', name it phone.js and save it in the corresponding folder in 'myPackage' (hint: /packages/myPackage/server/models/)&lt;br /&gt;
A product needs to have the following fields with specific types. Here is an example of a Phone object can be stored in the MongoDB:&lt;br /&gt;
&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;age&amp;quot;: 0, &lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;motorola-xoom-with-wi-fi&amp;quot;, &lt;br /&gt;
        &amp;quot;imageUrl&amp;quot;: &amp;quot;img/phones/motorola-xoom-with-wi-fi.0.jpg&amp;quot;, &lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;Motorola XOOM\u2122 with Wi-Fi&amp;quot;, &lt;br /&gt;
        &amp;quot;snippet&amp;quot;: &amp;quot;The Next, Next Generation\r\n\r\nExperience the future with Motorola XOOM with Wi-Fi, the world's first tablet powered by Android 3.0 (Honeycomb).&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
This is taken from phones.json used by the AngularJS tutorial. If you have gone through the tutorial, you should have realized that instead of using a DB, json files were used to simplify the tutorial.&lt;br /&gt;
Find phones.json in /app/phones in the angular tutorial folder and try importing its content to MongoDB so you can use them in your current MEAN package.&lt;br /&gt;
&lt;br /&gt;
*Run '''mongod''' and connect to mongo shell (mongo --shell), then type &amp;quot;use mean-dev&amp;quot; to switch to database used by mean.&lt;br /&gt;
*Type  mongoimport --db mean-dev --collection phones --type json --file ''&amp;lt;path to phones.json&amp;gt;'' --jsonArray&lt;br /&gt;
*Type show collections to see if phones are added to your database, type coll = db.phones to see the content of the file.&lt;br /&gt;
&lt;br /&gt;
== Controllers ==&lt;br /&gt;
Find article.js in the controllers folder. Try to understand what each part does.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== View == &lt;br /&gt;
Let's switch to the public folder where the views &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Packages === &lt;br /&gt;
* Create a package and locate it. Compare the file structure&lt;br /&gt;
Once you init and run an app,&lt;/div&gt;</summary>
		<author><name>Vigo</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=1704</id>
		<title>Getting MEAN</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=1704"/>
		<updated>2014-04-30T02:54:38Z</updated>

		<summary type="html">&lt;p&gt;Vigo: Created page with '=== Installation === * To install MEAN, follow instructions [http://mean.io/#!/docs here] on how to get started.  * Take a moment and read the rest of the documentations to get f…'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Installation ===&lt;br /&gt;
* To install MEAN, follow instructions [http://mean.io/#!/docs here] on how to get started. &lt;br /&gt;
* Take a moment and read the rest of the documentations to get familiar with the file structure and idioms.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Running the Default App ===&lt;br /&gt;
* Init and run an app. Make sure MongoDB is connected and running (if you run into problems, refer to the section on MongoDB)&lt;br /&gt;
* Explore features of the default Article app (such as logging in, adding/deleting articles).&lt;br /&gt;
&lt;br /&gt;
=== Generating a Package === &lt;br /&gt;
* By now you should know what a package is in MEAN. If you don't, read [http://mean.io/#!/docs this].&lt;br /&gt;
* Try creating a package named myPackage and locate it inside the packages folder&lt;br /&gt;
* Compare the structure of myPackage folder to that of the default app. Make sure you see both '''public''' and  '''server''' folders and their subfolders.&lt;br /&gt;
* Restart your app, make sure you can see a link to the newly created package.&lt;br /&gt;
&lt;br /&gt;
=== A Closer Look at the App ===&lt;br /&gt;
Take a look at the directory where you app resides, you will see two folders '''public''' and  '''server''', which contain code for the client side and server side respectively.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Model ==&lt;br /&gt;
Find article.js in /server/models, read the code, if you have trouble understanding what the code does, review the Mongoose [http://mongoosejs.com/docs/index.html quick start] guide.&lt;br /&gt;
&lt;br /&gt;
= Practice = &lt;br /&gt;
Define a schema for a model named '''Phone''', name it phone.js and save it in the corresponding folder in 'myPackage' (hint: /packages/myPackage/server/models/)&lt;br /&gt;
A product needs to have the following fields with specific types. Here is an example of a Phone object can be stored in the MongoDB:&lt;br /&gt;
&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;age&amp;quot;: 0, &lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;motorola-xoom-with-wi-fi&amp;quot;, &lt;br /&gt;
        &amp;quot;imageUrl&amp;quot;: &amp;quot;img/phones/motorola-xoom-with-wi-fi.0.jpg&amp;quot;, &lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;Motorola XOOM\u2122 with Wi-Fi&amp;quot;, &lt;br /&gt;
        &amp;quot;snippet&amp;quot;: &amp;quot;The Next, Next Generation\r\n\r\nExperience the future with Motorola XOOM with Wi-Fi, the world's first tablet powered by Android 3.0 (Honeycomb).&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
This is taken from phones.json used by the AngularJS tutorial. If you have gone through the tutorial, you should have realized that instead of using a DB, json files were used to simplify the tutorial.&lt;br /&gt;
Find phones.json in /app/phones in the angular tutorial folder and try importing its content to MongoDB so you can use them in your current MEAN package.&lt;br /&gt;
&lt;br /&gt;
Run '''mongod''' and connect to mongo shell (mongo --shell), then type &amp;quot;use mean-dev&amp;quot; to switch to database used by mean.&lt;br /&gt;
Type  mongoimport --db mean-dev --collection phones --type json --file ''&amp;lt;path to phones.json&amp;gt;'' --jsonArray&lt;br /&gt;
Type show collections to see if phones are added to your database, type coll = db.phones to see the content of the file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== View == &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Packages === &lt;br /&gt;
* Create a package and locate it. Compare the file structure&lt;br /&gt;
Once you init and run an app,&lt;/div&gt;</summary>
		<author><name>Vigo</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_9&amp;diff=1703</id>
		<title>Module 9</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_9&amp;diff=1703"/>
		<updated>2014-04-30T02:00:17Z</updated>

		<summary type="html">&lt;p&gt;Vigo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
&lt;br /&gt;
This module introduces MEAN, a fullstack web framework that uses '''M'''ongoDB, '''E'''xpress, '''A'''ngularJS and '''N'''ode.js. &amp;lt;br/&amp;gt;&lt;br /&gt;
You have already learned (some things) about Node.js. In this module, you will be introduced to other three new technologies. Don’t frown yet, the goal of this module is to introduce you to the concept of web frameworks and prepare you for the creative project. You are not required to be an expert in all of these technologies, however, it’s important to understand the basics of each and how they work together.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Reading ==&lt;br /&gt;
&lt;br /&gt;
The following articles on the online class wiki textbook contain information that will help you complete the assignment.&lt;br /&gt;
&lt;br /&gt;
*[[MongoDB]]&lt;br /&gt;
*[[Express]] &lt;br /&gt;
*[[AngularJS]]&lt;br /&gt;
*[[Getting MEAN]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Individual Assignments ==&lt;br /&gt;
&lt;br /&gt;
=== Tutorials ===&lt;br /&gt;
&lt;br /&gt;
Make sure you go through tutorials for both MongoDB and AngularJS, and understand how Express works.&lt;br /&gt;
&lt;br /&gt;
=== Install MEAN ===&lt;br /&gt;
&lt;br /&gt;
Follow the steps and install MEAN on your machine, initialize an app and type grunt in your terminal to start the server (make sure your mongoDB server is connected and running).&lt;br /&gt;
Open up the app in your browser (localhost:3000), and understand what the default app does.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Group Project ==&lt;br /&gt;
* Make an e-commerce site using the MEAN stack.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To start, come up with use cases for your site. Think about what products the site is selling, what the user can do, and how information is stored etc.&lt;br /&gt;
&lt;br /&gt;
You may start with the default MEAN.io app and build on top of it. This way you don't have to implement user authentication. You can also create a MEAN package and start from there. &amp;lt;br/&amp;gt;&lt;br /&gt;
You may use phone models provided by the Angular Phone Catalog app as your products. Review the MongoDB section on how to import JSON data into MongoDB.&lt;br /&gt;
&lt;br /&gt;
==== Tips ====&lt;br /&gt;
&lt;br /&gt;
Review the &amp;quot;Getting MEAN&amp;quot; section to understand the file system so you know how components work with each other.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Please save your file as ''birthday.html'' from the plain text editor of your choice.&lt;br /&gt;
&lt;br /&gt;
'''Important Note:''' Writing your web page in a word processor like Microsoft Word or even WordPad or TextEdit will ''not'' work.  What you need is a plain text editor.&lt;br /&gt;
&lt;br /&gt;
==== How to View Your HTML Document ====&lt;br /&gt;
&lt;br /&gt;
Once you have ''birthday.html'', you can open it using your favorite web browser (like Firefox).  For the purposes of this exercise, it suffices to right-click the file and tell it to &amp;quot;open with&amp;quot; Firefox.  When the file opens, it should be under the file:/// protocol.&lt;br /&gt;
&lt;br /&gt;
In Module 2, we will install a web server that serves up pages on the http:// protocol.&lt;br /&gt;
&lt;br /&gt;
==== Validation ====&lt;br /&gt;
&lt;br /&gt;
'''Your birthday card must pass the W3C Validator with no errors.'''  From [http://validator.w3.org/ the validator], you can choose to upload your file.&lt;br /&gt;
&lt;br /&gt;
For more information on validation, see the HTML and CSS guide: [[HTML and CSS#Validation]]&lt;br /&gt;
&lt;br /&gt;
=== Make a Portal to a DuckDuckGo Search ===&lt;br /&gt;
&lt;br /&gt;
'''Write an HTML document containing a form that searches DuckDuckGo's web site.'''  You should be able to type in a search term and have your form load the DuckDuckGo search page.&lt;br /&gt;
&lt;br /&gt;
# Visit [https://www.duckduckgo.com/ www.duckduckgo.com].  Search for something easy to spot in the URL, like &amp;quot;QUERY&amp;quot;.&lt;br /&gt;
# Look at the URL of the search page.  What is the script URL?  What is the query variable?&lt;br /&gt;
# Make an HTML document containing a text field and a submit button.  Typing a search query into the text field and pressing the submit button should load the DuckDuckGo search page.&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
We will be grading the following aspects of your work.  There are 50 points total.&lt;br /&gt;
&lt;br /&gt;
# '''Birthday Card (30 Points):'''&lt;br /&gt;
#* Correct usage of HTML and CSS in your birthday card (10 points).&lt;br /&gt;
#*: ''Make sure that you use HTML for &amp;quot;content&amp;quot; and CSS for &amp;quot;appearance.&amp;quot;  Don't write inline styles: use a stylesheet.''&lt;br /&gt;
#* Experimenting with at least 5 different CSS properties in your birthday card (10 points).&lt;br /&gt;
#* Birthday card passes the W3C validation for the declared DOCTYPE (e.g., HTML 5) (10 points).&lt;br /&gt;
# '''Search Portal (15 Points):'''&lt;br /&gt;
#* DuckDuckGo search portal is functional (15 points).&lt;br /&gt;
# '''Account Created on Amazon Web Services (5 Points)'''&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 1]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Vigo</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_9&amp;diff=1702</id>
		<title>Module 9</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_9&amp;diff=1702"/>
		<updated>2014-04-30T01:55:24Z</updated>

		<summary type="html">&lt;p&gt;Vigo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
&lt;br /&gt;
This module introduces MEAN, a fullstack web framework that uses '''M'''ongoDB, '''E'''xpress, '''A'''ngularJS and '''N'''ode.js. &amp;lt;br/&amp;gt;&lt;br /&gt;
You have already learned (some things) about Node.js. In this module, you will be introduced to other three new technologies. Don’t frown yet, the goal of this module is to introduce you to the concept of web frameworks and prepare you for the creative project. You are not required to be an expert in all of these technologies, however, it’s important to understand the basics of each and how they work together.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Reading ==&lt;br /&gt;
&lt;br /&gt;
The following articles on the online class wiki textbook contain information that will help you complete the assignment.&lt;br /&gt;
&lt;br /&gt;
*[[MongoDB]]&lt;br /&gt;
*[[Express]] &lt;br /&gt;
*[[AngularJS]]&lt;br /&gt;
*[[Getting MEAN]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Individual Assignments ==&lt;br /&gt;
&lt;br /&gt;
=== Tutorials ===&lt;br /&gt;
&lt;br /&gt;
Make sure you go through tutorials for both MongoDB and AngularJS, and understand how Express works.&lt;br /&gt;
&lt;br /&gt;
=== Install MEAN ===&lt;br /&gt;
&lt;br /&gt;
Follow the steps and install MEAN on your machine, initialize an app and type grunt in your terminal to start the server (make sure your mongoDB server is connected and running).&lt;br /&gt;
Open up the app in your browser (localhost:3000), and understand what the default app does.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Group Project ==&lt;br /&gt;
* &lt;br /&gt;
* Make an e-commerce site using the MEAN stack.&lt;br /&gt;
* &lt;br /&gt;
&lt;br /&gt;
To start, come up with use cases for your site. Think about what products the site is selling, what the user can do, and how information is stored etc.&lt;br /&gt;
&lt;br /&gt;
You may start with the default MEAN.io app and build on top of it. This way you don't have to implement user authentication. You can also create a MEAN package and start from there. &amp;lt;br/&amp;gt;&lt;br /&gt;
You may use phone models provided by the Angular Phone Catalog app as your products. Review the MongoDB section on how to import JSON data into MongoDB.&lt;br /&gt;
&lt;br /&gt;
==== How to Edit Your File ====&lt;br /&gt;
&lt;br /&gt;
Starting in Module 2, we will be using Komodo Edit as our primary development tool.  However, for the purposes of this exercise, we want you to edit your HTML file using a more basic text editor.&lt;br /&gt;
&lt;br /&gt;
* On Windows, consider Notepad++.  This is already installed for you in the CEC labs.  If you prefer to use your personal computer, you can download it from [http://notepad-plus-plus.org/ here].&lt;br /&gt;
* On Mac OS X, consider TextWrangler.  You can download it from [http://www.barebones.com/products/textwrangler/ here] or from the Apple App Store.&lt;br /&gt;
* Most Linux distributions come with gedit pre-installed, which you can use for this lab.&lt;br /&gt;
&lt;br /&gt;
Please save your file as ''birthday.html'' from the plain text editor of your choice.&lt;br /&gt;
&lt;br /&gt;
'''Important Note:''' Writing your web page in a word processor like Microsoft Word or even WordPad or TextEdit will ''not'' work.  What you need is a plain text editor.&lt;br /&gt;
&lt;br /&gt;
==== How to View Your HTML Document ====&lt;br /&gt;
&lt;br /&gt;
Once you have ''birthday.html'', you can open it using your favorite web browser (like Firefox).  For the purposes of this exercise, it suffices to right-click the file and tell it to &amp;quot;open with&amp;quot; Firefox.  When the file opens, it should be under the file:/// protocol.&lt;br /&gt;
&lt;br /&gt;
In Module 2, we will install a web server that serves up pages on the http:// protocol.&lt;br /&gt;
&lt;br /&gt;
==== Validation ====&lt;br /&gt;
&lt;br /&gt;
'''Your birthday card must pass the W3C Validator with no errors.'''  From [http://validator.w3.org/ the validator], you can choose to upload your file.&lt;br /&gt;
&lt;br /&gt;
For more information on validation, see the HTML and CSS guide: [[HTML and CSS#Validation]]&lt;br /&gt;
&lt;br /&gt;
=== Make a Portal to a DuckDuckGo Search ===&lt;br /&gt;
&lt;br /&gt;
'''Write an HTML document containing a form that searches DuckDuckGo's web site.'''  You should be able to type in a search term and have your form load the DuckDuckGo search page.&lt;br /&gt;
&lt;br /&gt;
# Visit [https://www.duckduckgo.com/ www.duckduckgo.com].  Search for something easy to spot in the URL, like &amp;quot;QUERY&amp;quot;.&lt;br /&gt;
# Look at the URL of the search page.  What is the script URL?  What is the query variable?&lt;br /&gt;
# Make an HTML document containing a text field and a submit button.  Typing a search query into the text field and pressing the submit button should load the DuckDuckGo search page.&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
We will be grading the following aspects of your work.  There are 50 points total.&lt;br /&gt;
&lt;br /&gt;
# '''Birthday Card (30 Points):'''&lt;br /&gt;
#* Correct usage of HTML and CSS in your birthday card (10 points).&lt;br /&gt;
#*: ''Make sure that you use HTML for &amp;quot;content&amp;quot; and CSS for &amp;quot;appearance.&amp;quot;  Don't write inline styles: use a stylesheet.''&lt;br /&gt;
#* Experimenting with at least 5 different CSS properties in your birthday card (10 points).&lt;br /&gt;
#* Birthday card passes the W3C validation for the declared DOCTYPE (e.g., HTML 5) (10 points).&lt;br /&gt;
# '''Search Portal (15 Points):'''&lt;br /&gt;
#* DuckDuckGo search portal is functional (15 points).&lt;br /&gt;
# '''Account Created on Amazon Web Services (5 Points)'''&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 1]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Vigo</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_9&amp;diff=1701</id>
		<title>Module 9</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_9&amp;diff=1701"/>
		<updated>2014-04-30T01:18:47Z</updated>

		<summary type="html">&lt;p&gt;Vigo: Created page with '__NOTOC__   This module introduces MEAN, a fullstack web framework that uses '''M'''ongoDB, '''E'''xpress, '''A'''ngularJS and '''N'''ode.js. &amp;lt;br/&amp;gt; You have already learned (some…'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
&lt;br /&gt;
This module introduces MEAN, a fullstack web framework that uses '''M'''ongoDB, '''E'''xpress, '''A'''ngularJS and '''N'''ode.js. &amp;lt;br/&amp;gt;&lt;br /&gt;
You have already learned (some things) about Node.js. In this module, you will be introduced to other three new technologies. Don’t frown yet, the goal of this module is to introduce you to the concept of web frameworks and prepare you for the creative project. You are not required to be an expert in all of these technologies, however, it’s important to understand the basics of each and how they work together.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Reading ==&lt;br /&gt;
&lt;br /&gt;
The following articles on the online class wiki textbook contain information that will help you complete the assignment.&lt;br /&gt;
&lt;br /&gt;
*[[MongoDB]]&lt;br /&gt;
*[[Express]] &lt;br /&gt;
*[[AngularJS]]&lt;br /&gt;
*[[Node.js]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Assignments ==&lt;br /&gt;
&lt;br /&gt;
=== Individual ===&lt;br /&gt;
&lt;br /&gt;
'''Write a birthday card to a friend or family member using HTML and CSS.'''  Use HTML to define the content of the card (like the headings and the paragraphs), and use CSS to define the appearance.  Some ideas:&lt;br /&gt;
&lt;br /&gt;
* Make the background-color of the page baby blue and use purple ink to write a card to a little boy&lt;br /&gt;
* Make the text big and red, and include pictures of hearts&lt;br /&gt;
* Use a boxy font with text shadows to make your card look urban (more advanced)&lt;br /&gt;
&lt;br /&gt;
Use this opportunity to experiment with the plethora of CSS properties.  Remember that you're in a computer science class (not an art class), so we don't care if your card looks ugly.  The main thing is that you learn HTML and CSS and use them appropriately.&lt;br /&gt;
&lt;br /&gt;
==== How to Edit Your File ====&lt;br /&gt;
&lt;br /&gt;
Starting in Module 2, we will be using Komodo Edit as our primary development tool.  However, for the purposes of this exercise, we want you to edit your HTML file using a more basic text editor.&lt;br /&gt;
&lt;br /&gt;
* On Windows, consider Notepad++.  This is already installed for you in the CEC labs.  If you prefer to use your personal computer, you can download it from [http://notepad-plus-plus.org/ here].&lt;br /&gt;
* On Mac OS X, consider TextWrangler.  You can download it from [http://www.barebones.com/products/textwrangler/ here] or from the Apple App Store.&lt;br /&gt;
* Most Linux distributions come with gedit pre-installed, which you can use for this lab.&lt;br /&gt;
&lt;br /&gt;
Please save your file as ''birthday.html'' from the plain text editor of your choice.&lt;br /&gt;
&lt;br /&gt;
'''Important Note:''' Writing your web page in a word processor like Microsoft Word or even WordPad or TextEdit will ''not'' work.  What you need is a plain text editor.&lt;br /&gt;
&lt;br /&gt;
==== How to View Your HTML Document ====&lt;br /&gt;
&lt;br /&gt;
Once you have ''birthday.html'', you can open it using your favorite web browser (like Firefox).  For the purposes of this exercise, it suffices to right-click the file and tell it to &amp;quot;open with&amp;quot; Firefox.  When the file opens, it should be under the file:/// protocol.&lt;br /&gt;
&lt;br /&gt;
In Module 2, we will install a web server that serves up pages on the http:// protocol.&lt;br /&gt;
&lt;br /&gt;
==== Validation ====&lt;br /&gt;
&lt;br /&gt;
'''Your birthday card must pass the W3C Validator with no errors.'''  From [http://validator.w3.org/ the validator], you can choose to upload your file.&lt;br /&gt;
&lt;br /&gt;
For more information on validation, see the HTML and CSS guide: [[HTML and CSS#Validation]]&lt;br /&gt;
&lt;br /&gt;
=== Make a Portal to a DuckDuckGo Search ===&lt;br /&gt;
&lt;br /&gt;
'''Write an HTML document containing a form that searches DuckDuckGo's web site.'''  You should be able to type in a search term and have your form load the DuckDuckGo search page.&lt;br /&gt;
&lt;br /&gt;
# Visit [https://www.duckduckgo.com/ www.duckduckgo.com].  Search for something easy to spot in the URL, like &amp;quot;QUERY&amp;quot;.&lt;br /&gt;
# Look at the URL of the search page.  What is the script URL?  What is the query variable?&lt;br /&gt;
# Make an HTML document containing a text field and a submit button.  Typing a search query into the text field and pressing the submit button should load the DuckDuckGo search page.&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
We will be grading the following aspects of your work.  There are 50 points total.&lt;br /&gt;
&lt;br /&gt;
# '''Birthday Card (30 Points):'''&lt;br /&gt;
#* Correct usage of HTML and CSS in your birthday card (10 points).&lt;br /&gt;
#*: ''Make sure that you use HTML for &amp;quot;content&amp;quot; and CSS for &amp;quot;appearance.&amp;quot;  Don't write inline styles: use a stylesheet.''&lt;br /&gt;
#* Experimenting with at least 5 different CSS properties in your birthday card (10 points).&lt;br /&gt;
#* Birthday card passes the W3C validation for the declared DOCTYPE (e.g., HTML 5) (10 points).&lt;br /&gt;
# '''Search Portal (15 Points):'''&lt;br /&gt;
#* DuckDuckGo search portal is functional (15 points).&lt;br /&gt;
# '''Account Created on Amazon Web Services (5 Points)'''&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 1]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Vigo</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=CSE_330_Online_Textbook_-_Table_of_Contents&amp;diff=1700</id>
		<title>CSE 330 Online Textbook - Table of Contents</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=CSE_330_Online_Textbook_-_Table_of_Contents&amp;diff=1700"/>
		<updated>2014-04-30T01:10:37Z</updated>

		<summary type="html">&lt;p&gt;Vigo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;div style=&amp;quot;text-align:center;&amp;quot;&amp;gt;[[File:CSE330Banner.png]]&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &lt;br /&gt;
&amp;lt;div style=&amp;quot;column-width: 300px; -moz-column-width: 300px; -webkit-column-width: 300px;&amp;quot;&amp;gt;&lt;br /&gt;
{{FrontPageModule&lt;br /&gt;
|num=1&lt;br /&gt;
|subject=HTML and CSS Fundamentals&lt;br /&gt;
|links=&lt;br /&gt;
* [[HTML and CSS]]&lt;br /&gt;
* [[HTML Forms]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{FrontPageModule&lt;br /&gt;
|num=2&lt;br /&gt;
|subject=Linux, Apache, and PHP&lt;br /&gt;
|links=&lt;br /&gt;
* [[Linux]]&lt;br /&gt;
* [[Bash]]&lt;br /&gt;
* [[Amazon Web Services]]&lt;br /&gt;
* [[SSH]]&lt;br /&gt;
* [[Apache]]&lt;br /&gt;
* [[PHP]]&lt;br /&gt;
* [[Workflow]]&lt;br /&gt;
* [[Web Application Security, Part 1]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{FrontPageModule&lt;br /&gt;
|num=3&lt;br /&gt;
|subject=SQL Databases&lt;br /&gt;
|links=&lt;br /&gt;
* [[Introduction to MySQL]] (installation)&lt;br /&gt;
* [[MySQL Schema and State]] (queries)&lt;br /&gt;
* [[PHP and MySQL]] (using MySQL from PHP)&lt;br /&gt;
* [[Web Application Security, Part 2]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{FrontPageModule&lt;br /&gt;
|num=4&lt;br /&gt;
|subject=Scripting for Rapid Prototyping&lt;br /&gt;
|links=&lt;br /&gt;
* [[Python]]&lt;br /&gt;
* [[Regular Expressions]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{FrontPageModule&lt;br /&gt;
|num=5&lt;br /&gt;
|subject=Version Control Systems and Web Frameworks&lt;br /&gt;
|links=&lt;br /&gt;
* [[Git]]&lt;br /&gt;
* [[Web Frameworks]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{FrontPageModule&lt;br /&gt;
|num=6&lt;br /&gt;
|subject=JavaScript and APIs&lt;br /&gt;
|links=&lt;br /&gt;
* [[JavaScript]]&lt;br /&gt;
* [[AJAX and JSON]]&lt;br /&gt;
* [[Ext JS]]&lt;br /&gt;
* [[Extensible Calendar]]&lt;br /&gt;
* [[Web Application Security, Part 3]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{FrontPageModule&lt;br /&gt;
|num=7&lt;br /&gt;
|subject=Real-Time Web Applications&lt;br /&gt;
|links=&lt;br /&gt;
* [[Node.JS]]&lt;br /&gt;
* [[Socket.IO]]&lt;br /&gt;
* [[Pong Game]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{FrontPageModule&lt;br /&gt;
|num=8&lt;br /&gt;
|subject=Creative Project&lt;br /&gt;
|links=&lt;br /&gt;
* [[Choosing a Platform]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{FrontPageModule&lt;br /&gt;
|num=9&lt;br /&gt;
|subject=MEAN Stack -- Javascript fullstack for web development&lt;br /&gt;
|links=&lt;br /&gt;
* [[MongoDB]]&lt;br /&gt;
* [[Express]]&lt;br /&gt;
* [[AngularJS]]&lt;br /&gt;
* [[Node.js]]&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reference ==&lt;br /&gt;
&lt;br /&gt;
Use this wiki as a starting place for your projects in CSE 330.  However, web development is a large field, so it is impossible for us to document everything you might need to know.  Here are some other places you should look when you need to find something:&lt;br /&gt;
&lt;br /&gt;
* [http://www.webplatform.org/ WebPlatform.org], a community-driven source containing documentation and tutorials for Web technologies&lt;br /&gt;
* [http://www.w3.org/community/webed/wiki/Main_Page The Web Education Community Group Wiki], also sponsored by the W3C.&lt;br /&gt;
* [http://reference.sitepoint.com/html SitePoint], which has a reference page as well as quality articles and tutorials&lt;br /&gt;
* Also take a look at [http://designfestival.com/13-time-saving-tools-for-web-designers/ this list of productivity tools] for web development.&lt;br /&gt;
&lt;br /&gt;
If you can't find what you need in any of these places, try using your favorite search engine.  '''Be wary of sites that come up on search engines.'''  Many HTML reference sites document bad practices and dated techniques.  If you're unsure whether a reference site you find is legitimate, ask a TA.&lt;br /&gt;
&lt;br /&gt;
== Want to Learn More? ==&lt;br /&gt;
&lt;br /&gt;
The limited amount of time in CSE 330 means that we can cover only a subset of the wide range of possible topics in the field of rapid prototyping and web development.  Indeed, the exact topics covered in CSE 330 change from year to year.&lt;br /&gt;
&lt;br /&gt;
Feel free to browse some of the topics that have previously been covered in CSE 330: [[:Category:Former Content|CSE 330 Former Content]]&lt;br /&gt;
&lt;br /&gt;
You should also consider following blogs like [http://www.sitepoint.com/ SitePoint] to keep up-to-date on the latest developments in the field of web development.&lt;br /&gt;
&lt;br /&gt;
== Content License ==&lt;br /&gt;
&lt;br /&gt;
The content of this wiki is copyright (c) 2013, Washington University in St. Louis, Department of Computer Science.  All rights reserved.&lt;br /&gt;
&lt;br /&gt;
=== Modified BSD License ===&lt;br /&gt;
&lt;br /&gt;
Redistribution and use in source and binary forms, with or without modification, by a Third Party who has not completed and is not in the process of completing CSE 330, of the code examples or concepts on this wiki, are permitted, provided that the following conditions are met:&lt;br /&gt;
&lt;br /&gt;
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.&lt;br /&gt;
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.&lt;br /&gt;
* Neither the name of the Washington University School of Engineering and Applied Science nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.&lt;br /&gt;
&lt;br /&gt;
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS TO ALL PARTIES &amp;quot;AS IS&amp;quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.&lt;br /&gt;
&lt;br /&gt;
=== What it Means ===&lt;br /&gt;
&lt;br /&gt;
If you are a student in CSE 330, you may use the code from this wiki freely in your projects without the need for attribution.  If you are not a student in CSE 330, you may use the code from this wiki freely in your projects with attribution.  Either way, the code examples are provided &amp;quot;as is&amp;quot;, without any warranty, and Washington University holds no liability for problems arising from the use of the content in this wiki.&lt;/div&gt;</summary>
		<author><name>Vigo</name></author>
		
	</entry>
</feed>