-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Submodules and components #9
Changes from 4 commits
1f5b257
961248c
6261d26
a318697
b6a13b5
a78c9f5
ed662a5
e69ca7d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<div> | ||
<h2>{{ message }}</h2> | ||
<hr /> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { TitleComponent } from './title.component'; | ||
|
||
describe('TitleComponent', () => { | ||
let component: TitleComponent; | ||
let fixture: ComponentFixture<TitleComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ TitleComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(TitleComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Component, Input } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'app-title', | ||
templateUrl: './title.component.html', | ||
styleUrls: ['./title.component.scss'] | ||
}) | ||
export class TitleComponent { | ||
@Input() | ||
message: string; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<div> | ||
<p>You can use @Input to decorate a field making it accept values sent by the component props.</p> | ||
<p>For example:</p> | ||
<pre> | ||
export class TitleComponent {{ '{' }} | ||
@Input() | ||
message: string; | ||
{{ '}' }} | ||
</pre> | ||
|
||
<p>And then you can call the component passing a value for message.</p> | ||
<pre> | ||
<app-title message="Hello world" /> | ||
</pre> | ||
|
||
<app-title message="Hello world"></app-title> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The component |
||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { InputComponent } from './input.component'; | ||
import { SharedModule } from '../../shared/shared.module'; | ||
|
||
describe('InputComponent', () => { | ||
let component: InputComponent; | ||
let fixture: ComponentFixture<InputComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ InputComponent ], | ||
imports: [SharedModule], | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(InputComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Component, Input } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'app-input', | ||
templateUrl: './input.component.html', | ||
styleUrls: ['./input.component.scss'] | ||
}) | ||
export class InputComponent { | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,19 @@ | ||
<div class="container-fluid"> | ||
<div class="Tutorials-container container-fluid"> | ||
<fieldset> | ||
<legend>TutorialsComponent</legend> | ||
<div> | ||
Tutorials | ||
<div class="row"> | ||
<div class="col-2"> | ||
<ul class="Tutorials-menu"> | ||
<li> | ||
<a routerLink="/tutorials/input" [routerLinkActive]="'active'">@Input</a> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can use |
||
</li> | ||
</ul> | ||
</div> | ||
<div class="col-10"> | ||
<div class="container-fluid"> | ||
<router-outlet></router-outlet> | ||
</div> | ||
</div> | ||
</div> | ||
</fieldset> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,16 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { Routes, RouterModule } from '@angular/router'; | ||
import { TutorialsComponent } from './tutorials.component'; | ||
import { InputComponent } from './input/input.component'; | ||
|
||
const routes: Routes = [ | ||
{ path: '', component: TutorialsComponent }, | ||
{ | ||
path: '', | ||
component: TutorialsComponent, | ||
children: [ | ||
{ path: 'input', component: InputComponent }, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This sub-module is loaded by the path |
||
], | ||
}, | ||
]; | ||
|
||
export const TutorialsRoutingModule = RouterModule.forChild(routes); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This decorator allows you to set the value of this field in the html markup.