Recupera codigo y metodos de otro componente |
En el componente a compartir, en,
@Component({
selector: 'ion-head',
templateUrl: './view-header.component.html',
styleUrls: ['./view-header.component.scss'],
})
.component.html
Añadiremos dentro del selector ('ion-head', en este caso), el codigo a compartir o "plantilla"
.component.ts, usamos el selector indicativo del codigo a añadir
.module.ts: declaramos y exportamos el propio componente
@NgModule({
declarations: [
ViewHeaderComponent
],
exports: [
ViewHeaderComponent
]
})
En el/los componentes donde vamos a importar, codigo o/y metodos,
en .module.ts:
@NgModule({
imports: [
--
ViewHeaderModule
],
--
})
En el .html donde vamos a importar, el html fuente se cargara en el selector, en este caso 'ion-head'.
Para llamar a los metodos de la plantilla, definiremos un identificador en le selector que hara de objeto fuente,
por ejemplo lo llamaremos #head, quedando,
<ion-head #head></ion-head>
<ion-button [click]="head.metodo()"></ion-button>
|
SERVER WEB PAGES
|
https://ionicframework.com/docs/angular/pwa
ng add @angular/pwa
npm install -g firebase-tools
firebase init
"Which Firebase CLI features do you want to set up for this folder?" Choose "Hosting: Configure and deploy Firebase Hosting sites."
"Select a default Firebase project for this directory:" Choose the project you created on the Firebase website.
"What do you want to use as your public directory?" Enter "www"
Configure as a single-page app (rewrite all urls to /index.html)?" Enter "Yes".
"File www/index.html already exists. Overwrite?" Enter "No".
A firebase.json config file is generated, lo cambiamos por:
{
"hosting": {
"public": "www",
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
],
"headers": [
{
"source": "/build/app/**",
"headers": [
{
"key": "Cache-Control",
"value": "public, max-age=31536000"
}
]
},
{
"source": "ngsw-worker.js",
"headers": [
{
"key": "Cache-Control",
"value": "no-cache"
}
]
}
]
}
}
En enviroments.ts anadimos:
export const environment = {
production: false,
firebaseConfig: {
apiKey: "#############################",
authDomain: "ecommerce-bc4c3.firebaseapp.com",
databaseURL: "######################",
projectId: "############",
storageBucket: "################",
messagingSenderId: "############",
appId: "############################",
measurementId: "###########"
}
};
ionic build --prod
firebase deploy
|