1

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>
2
  • Give a try to vuefire plugin Commented Jan 20, 2017 at 21:46
  • I will try it, but I have a solution now. I add the object value between the [] and it works! Commented Jan 20, 2017 at 21:50

1 Answer 1

0

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

ligler[1].weeks[ligler[1].currentWeek].day
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.