# Tour of Errors Challenge

### **Setup Directions**

**First create a week4 folder in challenges if you do not have one already and make that week4 folder your working directory in the terminal.**\
**While in the week4 folder create a clone (copy) of the following github repository in your cloud9 workspace**

\
**COMMAND:**

| **git clone https://github.com/SoftStackFactory/angular-heroes-errors** |
| ----------------------------------------------------------------------- |

\
\
**You can find the repository at** [**angular-heroes-errors**](https://github.com/SoftStackFactory/angular-heroes-errors)\
\
**Once the repo has been cloned into your workspace you will see a new directory called angular-heroes-errors. Within the angular-heroes-errors directory you will find a project nearly identical to the Tour Of Heroes Tutorial Project found in the** [**Angular Documentation**](https://angular.io/tutorial)**.**

\
**Next, change directories into the newly created error-app directory.**

| **cd angular-heroes-errors** |
| ---------------------------- |

\
**Next Check if our node version is up to date**

| **node -v** |
| ----------- |

**Before moving on within the newly cloned project, make sure that we have an up to date version of the Angular CLI by typing:**

| **ng -v** |
| --------- |

\
**If you installed it from a previous exercise, it should look something like this:**&#x20;

![](https://lh6.googleusercontent.com/DNJQCgiAUS3RU_mRUBDvHJx4rNmBvKmWekXeJG1gONpu95zknHxHClbPm0ibxsHp7H0vpqVPgdhljpxQxAfIf41asIJlWRT11zOSH4d0G931EYjOQFamzZUktuxkPQl3OLnq3-Xv)

**If the command is not found, install the most up to date angular cli**

| <p><strong>npm install -g @angular/cli</strong><br></p> |
| ------------------------------------------------------- |

### **Serve Your Project**

**You should have this command saved somewhere here it is.**

| **ng serve** |
| ------------ |

**You will get an error here. Try to google it and figure it out before moving on.**\


**Install required dependencies**

| **npm install** |
| --------------- |

\
**Explanation:**

&#x20;**npm install is always needed to run after cloning an existing project. The reason why, is by default the repo you cloned does not have all of the applications dependencies included with it. Dependencies are just other code bases, libraries your app needs to run. The list of an applications dependencies is stored in a project’s package.json file, found in the apps root directory. This file has a list of the libraries the app needs to run, as well as the version of that library. When we run npm install it goes through the project’s package.json dependency list and installs all them in your node\_modules folder.** \


### **Environment Setup Recap**&#x20;

**We cloned or copied an existing angular project from github in Step 1. This is a common way we can inspect other people’s source code or projects. Last but not least we installed all of the project dependencies using Node Package Manager (NPM)m by running the command npm install.**

## **Objective**

### **Debug each branch utilizing your problem solving skills from your debugging tool belt.**

**Reference:** [**Angular Error Guide - How to fix errors**\
](https://docs.google.com/document/d/1TW4MGNqzqk3EUHC5Fh8voTLNHd82Qf2a_1nY3XW38QA/edit#heading=h.kk1966kbedef)

**Git Branches**\
**We will be using git branches in the  exercise. This is not the main focus of the lesson but we are using them in this lesson. So this part is for context.**\



![](https://lh6.googleusercontent.com/uroHg4BtiM2GbfdA9klcUSQugzdVV3IW6DL6hPfhHZyynqpn0AJxnCFbyilJ2b100JK6uZL8oWafOv32eJDc1P87d_he1RSBl2xK24jvJnqr5uP-NY1Yc0TZ7CSKDiFuNfJXUPU0)

**Git branches are just different timelines for our code base. In the above image, each circle is a commit, a snapshot of a moment in time of our codebase. The most current commits are on the right and are the most recent commits on their respective branches. The most recent commit made is called the head, the full purple circles on the end. In this case we have 2 branches named master and feature1. Feature1 branch was created after the second commit was made on the master repo so they both have the same first two commits, on the left. The commits that are on feature1 branch do not exist on the master branch. The feature1 branch does not have the last 3 commits that were made on the master branch. We can move back forth between branches in git. In short git branches are different timelines and in this case each one will have a different error on it.**

## **Our Challenge Git Process**&#x20;

**In this exercise there is a single error to be fixed in each branch. The name of the branch corresponds to the type of the error to give you some context. Some errors will be produced during the transpile and compiles stages, other during runtime.  The transpile and compile errors will show up in the terminal in cloud9. If the branch does not have an error during transpile then it will most likely be a runtime error which can be found in your chrome browser dev tools console.  Runtime errors happen when our application is run in the browser window and the error will show in the console or on the window. You must be using chrome web browser for this exercise.** \


1. **Lets first see what branches exist on the remote repo with**

| **git branch -a** |
| ----------------- |

\
**Result: Your font colors might be set different.**\
&#x20;**\*Note hit q to quit this branch list.**

![](https://lh4.googleusercontent.com/vOb1b5Yyv1RCk_D0X8hB7L_DkEYR8MhGPE6jLOEe_72PeG9vfKxDA8zIee01DdHb3D1wkEHa2gozl3YoFnkdfGLeW-8-nADEWa5UCBmeT2zG2cKVt6cSaaHD1f_OK3R09qBTFD2k)

1. **Explanation:**\
   &#x20;**This command git branch -a, lists all available local and remote branches. When we clone a repo we only get the master branch, not all the branches on the repository. Again remote meaning the repo we cloned from on github. In the image all the branches are listed local and remote. Local branches do not have remotes/ preceding them.**\
   **Now Copy branch a**\
   \
   &#x20;**Then hit Q  to close this menu**\
   \


![](https://lh3.googleusercontent.com/b7o3iYq3AR0wM_kmgBNrmLDh6fjH00I0uxs8RvwYDNMJJ9qmljhypHAwb1pUwy7VF8oDdbeXDy8gHgadMW32RMhV00uI8p3c0sRBBMhpMhkdXNy-neKyah1Mhf1Qyd3zRPzB-xyv)



**2. Paste the branch you copied for \<branch-name>**

| **git checkout \<branch-name>** |
| ------------------------------- |

\
&#x20;**Example:**&#x20;

| **git checkout remotes/origin/1-import-error** |
| ---------------------------------------------- |

![](https://lh3.googleusercontent.com/M0UJnF9mQ20f7IZQsX65tJmLZFVFIQ-5R5qQ5INDKiisT_C4k0RORyzZsLP9_S44kqizRXx5gyoHyaiqUYIM0NYK6coh2ynrNj7XiImPYiiyN_exSedvgm6e7aQcTSmN3Z6as139)

**The image above is stating we have a temporary unnamed branch to work around and make changes freely with no consequences. In the blue highlight is the last commit message made. This commit message will also have information relevant to the error on the branch.**\
\


1. **After you have fixed the error on the branch stage the file so we can commit it.**

| **git add .**  |
| -------------- |

\
**Command Explanation:  adds ALL files changed to be committed. If you do git status staged files to be including in the commit will be listed green.**\
\


![Screen Shot 2017-09-11 at 4.09.57 PM.png](https://lh4.googleusercontent.com/llRoet71H9BtPLXxt5yv3nXXWOrLqjldKjU8---aaxPOPms89eGioyHo7RI_WlOReDI7zUplIZytN8PYw-cC57V8i1aIfbyKCmnuZGSyn6Ychb1jVKNrt4rP7XKg0pTlFUU1eNB7)

| **git commit -m "your commit message here"** |
| -------------------------------------------- |

\
**This will save or commit changes in files we want to keep and mark them for a reference. Your commit message should be short but explain what your changes did or fixed.**

![Screen Shot 2017-09-11 at 4.09.18 PM.png](https://lh5.googleusercontent.com/CWVNXMENeACpQXJeMZPab9WRkNgbM7tgnMLcOK3P-KEvHrS9URvebVptetMvOh5mU2GDFoirJq6oYO6JTBlHZY_urQ7DavwVy9sV8xml5aoomHF40tLGwhiTsqKc1UjXwuqCsVYK)

1. **Now repeat the process going to the next branch. Look at branches in the local repo and repeat step one with a new branch.**\
   \


| **git branch -a** |
| ----------------- |

**This will list all branches on your local repository or repo.**\
&#x20;**You can also view the branches on the remote github repository.**

\
&#x20;[**Angular-Heroes-Errors Git Hub**](https://github.com/SoftStackFactory/angular-heroes-errors)

![](https://lh4.googleusercontent.com/UXuvzgQoQNvAIbbCdTJwC-GO-vZpQT7cGMh-pKSBoxH9NN__nRA1ZpxJt8tHldwBQmwmhh3kruE-HreqK3UkSO0ctkOODFj302SflWQ61MpVBCrTrD3WZRCJST2hl_c9gUP6o8uW)
