Hello!
I have a problem. A created a small application (Angular 4) with angular
material, and i used the <md-spinner></md-spinner>. But i think, i don't
use in all component html, but also in app.component.html.
The code is:
<!-- app component.html -->
<app-loader [loader]="loader"></app-loader>
/**
AppComponent
*/
import {Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
constructor() {}
loader: boolean;
}
/**
LoaderComponent
*/
import { Component, Input } from '@angular/core';
@Component({
selector: 'app-loader',
templateUrl: './loader.component.html',
styleUrls: ['./loader.component.sass']
})
export class LoaderComponent {
constructor() { }
@Input() loader: Boolean;
}
<!-- loader.component.html -->
<div class="loader" *ngIf="loader">
<md-spinner></md-spinner>
</div>
If i switch loader variable to true in AppComponent, loader is showed. But
i dont switch that from another component, because i use the RouterModule,
and don't use component like this:
<another-component></another-component>
When i use @Output, it's easy:
<another-component (loader)="foo($event)"></another-component>
import { Component } from '@angular/core';
@Component({
selector: 'app-another',
templateUrl: './another.component.html',
styleUrls: ['./another.component.sass']
})
export class AnotherComponent {
constructor() { }
@Output() loader: new EventEmitter();
}
/**
AppComponent
*/
import {Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
constructor() {}
*foo(ev) { // here is the event from another component...
console.log(ev); }*
}
It's work (sorry, if it has error, i written in a minute... ), but i dont
use this version, if i use Router. How can I solve it?
export const routes: Array<Route> = [
{
path: '',
redirectTo: '/home',
pathMatch: 'full'
},
{
path: 'home',
component: HomeComponent
},
{
path: 'another',
component: AnotherComponent
},
{ path: '**', component: PageNotFoundComponent }
];
Thanks for the all answer!!
--
You received this message because you are subscribed to the Google Groups
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.