I have a "tab" and would put it in the header, but I would like this "tab" and its elements were the same for all screens, as well as some .scss design. What is the best way to do this type of implementation?
I have a "tab" and would put it in the header, but I would like this "tab" and its elements were the same for all screens, as well as some .scss design. What is the best way to do this type of implementation?
You can do this by creating components on Ionic2.
Example 1: link
Example 2: I made a progress bar component. To do so I had to create a new component:
ionic g component progress-bar
Edit the files as needed:
components/progress-bar/progress-bar.ts
import { Component, Input } from '@angular/core';
@Component({
selector: 'progress-bar',
templateUrl: 'progress-bar.html'
})
export class ProgressBarComponent {
@Input('progress')
progress: number;
constructor() { }
}
components/progress-bar/progress-bar.html
<div class="progress-outer">
<div class="progress-inner" [style.width]="progress + '%'">
{{progress}}%
</div>
</div>
components/progress-bar/progress-bar.scss
progress-bar {
.progress-outer {
width: 96%;
margin: 10px 2%;
padding: 3px;
text-align: center;
background-color: #f4f4f4;
border: 1px solid #dcdcdc;
color: #fff;
border-radius: 20px;
}
.progress-inner {
min-width: 15%;
white-space: nowrap;
overflow: hidden;
padding: 5px;
border-radius: 20px;
background-color: #COR PRIMARIA DO SEU APP
}
}
Then declare it globally:
app/app.module.ts
import { ProgressBarComponent } from '../components/progress-bar/progress-bar'
@NgModule({
declarations: [
...
ProgressBarComponent
],
...
entryComponents: [
...
ProgressBarComponent
],
...
})
Now just use where you'd like to apply:
pages/exemplo/exemplo.html
...
<ion-content padding>
<progress-bar [progress]="progressoUpload" *ngIf="iniciadoUpload"></progress-bar>
...
To receive and send parameters between the components there are two important decorators @Input and @Output. Unfortunately I will not be able to LINKAR the documentation for their use. But in my example it has @Input