From the course: Angular: Testing and Debugging

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Add a new file using Angular CLI

Add a new file using Angular CLI - Angular Tutorial

From the course: Angular: Testing and Debugging

Start my 1-month free trial

Add a new file using Angular CLI

- [Instructor] Let's make a custom service that adds metadata to error messages before sending them to the console. There's a few ways we could add a new file, but I find the best way is to use Angular CLI tool. Angular CLI knows what type of file we want and automatically adds the correct imports and exports for that type of file. We'll need the terminal for this. So I'll go up to the Terminal menu, click on New Terminal and I'll type NG generate service and hit Enter. Angular will ask us what we want to name the file. Here's some things to keep in mind, Angular puts all new files in the app folder in the source directory, right here. We can declare sub-directories using forward slashes. For example, if I want to put something in the user folder I would type a user/ if I wanted to put something in a new folder I would type that name instead, so foo/, you get the idea. The file name itself is always transformed to lowercase dash case. This means a file called foo-bar and FooBar, with…

Contents