Skip to content

Conversation

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling e69ca7d on submodules-and-components into 1b16ded on master.

path: '',
component: TutorialsComponent,
children: [
{ path: 'input', component: InputComponent },
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sub-module is loaded by the path tutorials , so path here is going to be tutorials/input and will render the component InputComponent

<app-title message="Hello world" />
</pre>

<app-title message="Hello world"></app-title>
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The component Title has a field named message which is decorated with @Input(). This allows you to add a component and set the value of message.

styleUrls: ['./title.component.scss']
})
export class TitleComponent {
@Input()
Copy link
Owner Author

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.

<app-title message="some message"></app-title>

<div class="col-2">
<ul class="Tutorials-menu">
<li>
<a routerLink="/tutorials/input" [routerLinkActive]="'active'">@Input</a>
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use routerLinkActive to bind a class name that is going to be set on the element if the current route match the routerLink

@NgModule({
imports: [
CommonModule,
RouterModule,
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Required if any of your components use router-outlet

LayoutComponent,
TitleComponent,
],
declarations: [
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Components declared by this module

CommonModule,
RouterModule,
],
exports: [
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Components this module exports.

If you want to use any of these components in another module you can import SharedModule (this module) in the other module, anything that is exported here will be available in the other end.

imports: [
CommonModule,
TutorialsRoutingModule,
SharedModule,
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imports the TitleComponent used by InputComponent in this module.

TestBed.configureTestingModule({
declarations: [ TutorialsComponent ]
declarations: [ TutorialsComponent ],
imports: [RouterTestingModule],
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To test components that use router-outlet you need to import RouterTestingModule, a module specifically for tests.

@brunolm brunolm merged commit 779553b into master Nov 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants