Introduction
Angular has released its latest version, Angular 6.0. In this article, we will understand the new features of Angular 6.0 and also set up a new project with the help of Angular CLI 6.0 and Visual Studio Code.
- ng update: A new CLI command that will update your project dependencies to their latest versions.
- ng add: Another new CLI command that will make adding new capabilities to your project easier.
- Angular Elements: This is a new feature that allows us to compile Angular components to native web components which we can use in our Angular app.
- <template> element is deprecated: You can't use <template> anymore inside of your component templates. You need to use <ng-template> instead.
- Angular CLI now has the support for creating and building libraries. To create a library project within your CLI workspace run the following command:
ng generate library <name>
e.g. :- ng generate library my-demo-lib
- Angular Material Starter Components: If you run "ng add @angular/material" to add material to an existing application, you will also be able to generate 3 new starter component.
- Material Sidenav
A starter component including a toolbar with the app name and the side navigation. - Material Dashboard
A starter dashboard component containing a dynamic grid list of cards. - Material Data Table
A starter data table component that is pre-configured with a data source for sorting and pagination.
- Angular CLI now has support for workspaces containing multiple projects, such as multiple applications and/or libraries.
- The ".angular-cli.json" file has been deprecated. Angular projects will now use "angular.json" instead of ".angular-cli.json" for build and project configuration.
- Angular 6 will also allow us to use RxJS V6 with our application.
- Tree Shakable Providers: - Angular 6.0 allows us to bundle services into the code base in modules where they are injected. This will help us to make our application smaller.
- // In app.module.ts
- @NgModule({
- ...
- providers: [MyService]
- })
- export class AppModule {}
- // In myservice.ts
- import { Injectable } from '@angular/core';
- @Injectable()
- export class MyService {
- constructor() { }
- }
This approach will still work but Angular 6.0 provides a new and easier alternative to this. We no longer need to add references in our NgModule. We can inject the reference directly into the service. Therefore, we can use the service as below:
- // In myservice.ts
- import { Injectable } from '@angular/core';
- @Injectable({
- providedIn: 'root',
- })
- export class MyService {
- constructor() { }
- }
- node -v
- npm -v
Installing Angular CLI
Since node and npm are installed, the next step is to install Angular CLI. Run the following command in a command window.- npm i -g @angular/cli
Create the Angular 6 app
Open VS Code and navigate to View >> Integrated Terminal.
This will open a terminal window in VS Code.
Type the following sequence of commands in the terminal window. These commands will create a directory with name “ng6Demo” and then create an Angular application with the name “ng6App” inside that directory.- mkdir ng6Demo
- cd ng6Demo
- ng new ng6App

Hence, we have created our first Angular 6 application using VS Code and Angular CLI. Now, run the following command to open the project.
- code .

- {
- "name": "ng6-app",
- "version": "0.0.0",
- "scripts": {
- "ng": "ng",
- "start": "ng serve",
- "build": "ng build",
- "test": "ng test",
- "lint": "ng lint",
- "e2e": "ng e2e"
- },
- "private": true,
- "dependencies": {
- "@angular/animations": "^6.0.0",
- "@angular/common": "^6.0.0",
- "@angular/compiler": "^6.0.0",
- "@angular/core": "^6.0.0",
- "@angular/forms": "^6.0.0",
- "@angular/http": "^6.0.0",
- "@angular/platform-browser": "^6.0.0",
- "@angular/platform-browser-dynamic": "^6.0.0",
- "@angular/router": "^6.0.0",
- "core-js": "^2.5.4",
- "rxjs": "^6.0.0",
- "zone.js": "^0.8.26"
- },
- "devDependencies": {
- "@angular/compiler-cli": "^6.0.0",
- "@angular-devkit/build-angular": "~0.6.0",
- "typescript": "~2.7.2",
- "@angular/cli": "~6.0.0",
- "@angular/language-service": "^6.0.0",
- "@types/jasmine": "~2.8.6",
- "@types/jasminewd2": "~2.0.3",
- "@types/node": "~8.9.4",
- "codelyzer": "~4.2.1",
- "jasmine-core": "~2.99.1",
- "jasmine-spec-reporter": "~4.2.1",
- "karma": "~1.7.1",
- "karma-chrome-launcher": "~2.2.0",
- "karma-coverage-istanbul-reporter": "~1.4.2",
- "karma-jasmine": "~1.1.1",
- "karma-jasmine-html-reporter": "^0.2.2",
- "protractor": "~5.3.0",
- "ts-node": "~5.0.1",
- "tslint": "~5.9.1"
- }
- }
Execution Demo
The name of our Angular application is ng6app which is inside ng6demo directory.
So, we will first navigate to our application using the below commands.
- cd ng6demo
- cd ng6app
- ng serve

- import { Component } from '@angular/core';
- @Component({
- selector: 'app-root',
- templateUrl: './app.component.html',
- styleUrls: ['./app.component.css']
- })
- export class AppComponent {
- title = 'Csharp Corner';
- }
Now open the browser, you can see that the web page has been updated with new welcome message "Welcome to Csharp Corner!"
Conclusion
See Also
- Getting Started With Angular 5 Using Visual Studio Code
- CRUD Operations With ASP.NET Core Using Angular 5 And ADO.NET
- ASP.NET Core - CRUD Using Angular 5 And Entity Framework Core
- ASP.NET Core - Using Highcharts With Angular 5
https://blog.angular.io/version-6-of-angular-now-available-cc56b0efa7a4

RahulPosted May 29, 2018, 6:30 AM
This was a good read..
Prashant RewatkarPosted May 9, 2018, 4:44 AM
Hi ankit, could you please provide an arrival on CRUD operation in ng 6.
Mithilesh YadavPosted May 7, 2018, 4:42 AM
Hi Ankit, After upgrading to angular 6, .map not working for Observable. "[ts] Property 'map' does not exist on type 'Observable<Response>'. " this is the error i am getting. Please help.
Dinesh BeniwalPosted May 7, 2018, 1:06 AM
Thank you for sharing
Rajesh GamiPosted May 6, 2018, 10:02 PM
Nicely explain sir
Bryian TanPosted May 6, 2018, 9:35 PM
I don't think Material Sideman exists, should be Material Sidenav