Join the Stack Overflow Community
Stack Overflow is a community of 6.6 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

I use Firebase to store the database, and have a object currentWeek with a value off the current week.

I want to store the value of this object in a variable to call it.

Currently I'm using this to get the current week, but I want to get the current week from the database:

    <template>
  <div id="app">
      <div v-if="ligler[1]">
      <h3>{{ligler[1].weeks[currentWeek].day}}</h3>
  </div>
</template>

<script>
import Firebase from 'firebase'

let config = {
    apiKey: "xxxx",
    authDomain: "xxx.firebaseapp.com",
    databaseURL: "https://xxx.firebaseio.com"
}

let app = Firebase.initializeApp(config);
let db = app.database();

let ligRef = db.ref('ligler');

export default {
  name: 'app',
  firebase: {
    ligler: ligRef
  },
  data() {
      return {
        currentWeek: 18
      }
  }
}
</script>

I tried this, but it doesn't work:

data() {
      return {
        currentWeek: ligler[1].currentWeek
      }
  }

The database look like:

The database look like

How can I assign the value of currentWeek to a variable in vue.js? To use it in the code as [currentWeek]:

<h3>{{ligler[1].weeks[currentWeek].day}}</h3>
share|improve this question
    
Give a try to vuefire plugin – AldoRomo88 2 days ago
    
I will try it, but I have a solution now. I add the object value between the [] and it works! – Can 2 days ago

I have a solution, I add the object value between the [] and it works!!!

ligler[1].weeks[ligler[1].currentWeek].day
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.