0

I want to pass the value in one variable from one component to another component, this is what i got (Is angular1)

  BuscarPlaya(){
console.log("Prueba");
var pais = $("#paisSelect").val();
var provincia = $("#provinciaSelect").val();
var ciudad = $("#ciudadSelect").val();
var playas= $("#playaSelect").val();
console.log(pais);
console.log(provincia);
console.log(ciudad);
console.log(playas);

if ((ciudad=="2")){
  this.comillas=true;
} else if ((ciudad=="1")){
  this.santander=true;
}

if ((pais=="1") && (provincia=="1")&&(ciudad=="1")&&(playas=="1")){
  console.log("se escogio la playa el sardinero");
  this.latitudBusqueda=43.473424;
  this.longitudBusqueda=-3.782104;
}
}

i tried doing it by this way, but its not working

    import { Component, OnInit, Input} from '@angular/core';
    import { AgmCoreModule } from '@agm/core';

    @Component({
    selector: 'app-prueba',
    templateUrl: './prueba.component.html',
    styleUrls: ['./prueba.component.css']
    })
    export class PruebaComponent implements OnInit {
    @Input('latitudBusqueda') lat:number;
    @Input('longitudBusqueda') lng:number;

    constructor() { }

    ngOnInit() {
    }
    }

how can i get this variables to work in my PruebaComponent html

  • Also see https://angular.io/guide/component-interaction – Henry Sep 30 '17 at 12:02
  • The answer in this thread is exactly what you are looking for: https://stackoverflow.com/questions/35985009/angular-2-what-is-equivalent-to-root-scope – user3301565 Sep 30 '17 at 15:55

0 Answers0