Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

194
Vistas
How to display list data from script to template in vue?

I have the function of display data from major table on MySQL. I want to display the type of that list of major by comparing with the id of the faculty table like below. I have it displayed on console.log, how do I display it on the template? Thanks

Template tag

<td>
{{ inputText }}
</td>

Script tag

data() {
return {
    majors:[],
    faculties:[],
    form: new Form({
        major_id:'',
        major_code:'',
        major_name:'',
        major_faculty:'',
        major_status: '',
    }),
    inputText: '',
  };
},
computed: {
 filterFaculty() {
    for(let i in this.majors) {
        this.faculties.forEach((element) => {
            if(element.faculty_code==this.majors[i].major_faculty) {
                this.inputText=element.faculty_name;
            }else {
                return '-';
            }
        });
     }
  }
},
mounted() {
  this.fetchFaculties();
  this.fetchMajors();
},
methods: {
  fetchFaculties(page_url) {
    let vm = this;
    page_url = '../../api/admin/edu-faculty/faculty/faculty';
    fetch(page_url)
    .then(res => res.json())
    .then(res => {
        this.faculties = res.data;
    })
    .catch(err => console.log(err));
},
fetchMajors(page_url) {
    let vm = this;
    page_url = '../../api/admin/edu-major/major/'+this.currentEntries+'?page='+this.pagination.current_page;
    fetch(page_url)
    .then(res => res.json())
    .then(res => {
        this.majors = res.data;
        this.pagination = res.meta;
    })
    .catch(err => console.log(err));
  },
 }
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I've found solution for problem

Script tag

methods: {
   filterFaculty(major) {
      const faculty = this.faculties.find((fac) => fac.faculty_code === major.major_faculty);
        return faculty.faculty_name;
    },
}

Template tag

<td>
   {{ filterFaculty(major) }}
 </td>
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda