Last active
October 13, 2018 22:16
-
-
Save nonlogos/070fb97ae3b863ce581940ce0220edaa to your computer and use it in GitHub Desktop.
Angular5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component } from '@angular/core'; | |
@Component({ | |
selector: 'app-root', | |
templateUrl: './app.component.html', | |
styleUrls: ['./app.component.css'] | |
}) | |
export class AppComponent { | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { BrowserModule } from '@angular/platform-browser'; | |
import { NgModule } from '@angular/core'; | |
import { FormsModule } from '@angular/form'; | |
import { HttpModule } from '@angular/http'; | |
import { AppComponent } from './app.component'; | |
import { ServerComponent } from './server.component'; | |
@NgModule({ | |
declarations: [ | |
AppComponent, | |
ServerComponent // put any new components you made here | |
], | |
imports: [ | |
BrowserModule, | |
FormModule, | |
HttpModule | |
], | |
providers: [], | |
bootstrap: [AppComponent] | |
}) | |
export class AppModule {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// add a new component: server | |
// create a server folder | |
// add a server.component.ts | |
// add a server.component.html | |
// add a server.component.css | |
// add the component to the app.module file | |
// then add the component to the app.component.html file | |
// server.component.ts | |
import { Component } from '@angular/core'; | |
// add component decorator to enhance element in our code | |
@Component({ | |
selector: 'app-server', //needs to be an unique identifier | |
templateUrl: './server.component.html', | |
}) | |
export class ServerComponent { | |
} | |
// or new component onInit | |
import { Component, OnInit } from '@angular/core'; | |
@Component({ | |
selector: 'app-servers', | |
template: `<app-server></app-server> | |
<app-server></app-server> | |
`, | |
styleUrls: ['./servers.component.css'] | |
}) | |
export class ServersComponent implements OnInit { | |
constructor() { | |
} | |
ngOnInit() { | |
} | |
} | |
// app.component.html | |
<h3>I'm in the component</h3> | |
<hr> | |
<app-server></app-server> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment