Install CLI -
It might help you guys.
https://www.code-sample.com/2018/05/angular-2-4-5-6-7-8-interview-questions.html
npm install -g @angular/cli
And it looks like –
D:\Angular\AngularMaterial>npm install -g @angular/cli
[ ......] \ remove:@ngtools/webpack: sill remove C:\Users\Viaindia\AppData\Roaming\npm\node_modules\@angular\[ ......] - finalize:y18n: sill finalize C:\UsC:\Users\Viaindia\AppData\Roaming\npm\ng -> C:\Users\Viaindia\AppData\Roaming\npm\node_modules\@angular\cli\bin\ng
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules\@angular\cli\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
+ @angular/cli@1.7.3
added 60 packages, removed 265 packages, updated 115 packages and moved
10 packages in 85.446s
Install in in your project directory –
ng new ng5material
Here ng5material
is a project name and it looks like –
D:\Angular\AngularMaterial>ng new ng5material
create ng5material/e2e/app.e2e-spec.ts (293 bytes)
create ng5material/e2e/app.po.ts (208 bytes)
create ng5material/e2e/tsconfig.e2e.json (235 bytes)
create ng5material/karma.conf.js (923 bytes)
create ng5material/package.json (1296 bytes)
create ng5material/protractor.conf.js (722 bytes)
create ng5material/README.md (1027 bytes)
create ng5material/tsconfig.json (363 bytes)
create ng5material/tslint.json (3012 bytes)
create ng5material/.angular-cli.json (1246 bytes)
create ng5material/.editorconfig (245 bytes)
create ng5material/.gitignore (544 bytes)
create ng5material/src/assets/.gitkeep (0 bytes)
create ng5material/src/environments/environment.prod.ts (51 bytes)
create ng5material/src/environments/environment.ts (387 bytes)
create ng5material/src/favicon.ico (5430 bytes)
create ng5material/src/index.html (298 bytes)
create ng5material/src/main.ts (370 bytes)
create ng5material/src/polyfills.ts (3114 bytes)
create ng5material/src/styles.css (80 bytes)
create ng5material/src/test.ts (642 bytes)
create ng5material/src/tsconfig.app.json (211 bytes)
create ng5material/src/tsconfig.spec.json (283 bytes)
create ng5material/src/typings.d.ts (104 bytes)
create ng5material/src/app/app.module.ts (316 bytes)
create ng5material/src/app/app.component.html (1141 bytes)
create ng5material/src/app/app.component.spec.ts (986 bytes)
create ng5material/src/app/app.component.ts (207 bytes)
create ng5material/src/app/app.component.css (0 bytes)
added 1273 packages in 53.495s
'git' is not recognized as an internal or external command,
operable program or batch file.
Project 'ng5material' successfully created.
Install Angular Material in your project
directory–
npm install --save @angular/material @angular/cdk
And it looks like –
D:\Angular\AngularMaterial>cd ng5material
D:\Angular\AngularMaterial\ng5material>npm install --save @angular/material @angular/cdk
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
+ @angular/cdk@5.2.4
+ @angular/material@5.2.4
added 2 packages in 10.765s
Install Angular Animations in your project
directory–
npm install --save @angular/animations
And it looks like -
D:\Angular\AngularMaterial\ng5material>npm install --save @angular/animations
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
+ @angular/animations@5.2.8
updated 1 package in 10.011s
Create model in your project src folder –
ng g module ngmaterial
And it looks like –
D:\Angular\AngularMaterial\ng5material> ng g module ngmaterial
create src/app/ngmaterial/ngmaterial.module.ts (194 bytes)
Create component in your project src folder –
ng g component InputFormMaterial
And it looks like –
D:\Angular\AngularMaterial\ng5material>ng g component InputFormMaterial
create src/app/input-form-material/input-form-material.component.html (38 bytes)
create src/app/input-form-material/input-form-material.component.spec.ts (707 bytes)
create src/app/input-form-material/input-form-material.component.ts (319 bytes)
create src/app/input-form-material/input-form-material.component.css (0 bytes)
update src/app/app.module.ts (643 bytes)
Run your project using –
ng server --open
And it looks like –
D:\Angular\AngularMaterial\ng5material>ng server --open
** NG Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
11% building modules 15/16 modules 1 active ...modules\style-loader\lib\addStyles.jswebpack: wait until bundle finished: / Date: 2018-03-10T05:12:47.547Z
Hash: bdfa3a9fb554876f6fd2
Time: 10838ms
chunk {inline} inline.bundle.js (inline) 3.85 kB [entry] [rendered]
chunk {main} main.bundle.js (main) 21.4 kB [initial] [rendered]
chunk {polyfills} polyfills.bundle.js (polyfills) 549 kB [initial] [rendered]
chunk {styles} styles.bundle.js (styles) 41.5 kB [initial] [rendered]
chunk {vendor} vendor.bundle.js (vendor) 14.6 MB [initial] [rendered]
webpack: Compiled successfully.
Finally set your ngmaterial.module.ts -
import {CdkTableModule} from '@angular/cdk/table';
import {HttpClientModule} from '@angular/common/http';
import {NgModule} from '@angular/core';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import {HttpModule} from '@angular/http';
import {
MatAutocompleteModule,
MatButtonModule,
MatButtonToggleModule,
MatCardModule,
MatCheckboxModule,
MatChipsModule,
MatDatepickerModule,
MatDialogModule,
MatDividerModule,
MatExpansionModule,
MatGridListModule,
MatIconModule,
MatInputModule,
MatListModule,
MatMenuModule,
MatNativeDateModule,
MatPaginatorModule,
MatProgressBarModule,
MatProgressSpinnerModule,
MatRadioModule,
MatRippleModule,
MatSelectModule,
MatSidenavModule,
MatSliderModule,
MatSlideToggleModule,
MatSnackBarModule,
MatSortModule,
MatStepperModule,
MatTableModule,
MatTabsModule,
MatToolbarModule,
MatTooltipModule,
} from '@angular/material';
import {BrowserModule} from '@angular/platform-browser';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import {InputFormMaterialComponent} from '../input-form-material/input-form-material.component';
@NgModule({
exports: [
CdkTableModule,
MatAutocompleteModule,
MatButtonModule,
MatButtonToggleModule,
MatCardModule,
MatCheckboxModule,
MatChipsModule,
MatStepperModule,
MatDatepickerModule,
MatDialogModule,
MatDividerModule,
MatExpansionModule,
MatGridListModule,
MatIconModule,
MatInputModule,
MatListModule,
MatMenuModule,
MatNativeDateModule,
MatPaginatorModule,
MatProgressBarModule,
MatProgressSpinnerModule,
MatRadioModule,
MatRippleModule,
MatSelectModule,
MatSidenavModule,
MatSliderModule,
MatSlideToggleModule,
MatSnackBarModule,
MatSortModule,
MatTableModule,
MatTabsModule,
MatToolbarModule,
MatTooltipModule,
]
})
export class MaterialAppModule { }
app.module.ts –
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import {HttpClientModule} from '@angular/common/http';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import {HttpModule} from '@angular/http';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import {MaterialAppModule} from '../app/ngmaterial/ngmaterial.module'
import { AppComponent } from './app.component';
import {InputFormMaterialComponent} from '../app/input-form-material/input-form-material.component';
@NgModule({
imports: [
BrowserModule,
BrowserAnimationsModule,
MaterialAppModule ,
FormsModule,
HttpModule,
HttpClientModule,
ReactiveFormsModule
],
providers: [],
entryComponents: [InputFormMaterialComponent],
declarations: [InputFormMaterialComponent],
bootstrap: [InputFormMaterialComponent]
})
export class AppModule { }
platformBrowserDynamic().bootstrapModule(AppModule);
It might help you guys.
https://www.code-sample.com/2018/05/angular-2-4-5-6-7-8-interview-questions.html