I have to variables in my template "from" and "to" that loops through array of data in a select tag
i want to push the "from", "to" and the values in between to another array
like if the array was like this
[1,2,3,4,5,6,7,8,9,0]
if the user chose "2" in the from field and "6" in the "to" field i want to push "2" and "6" and the data in between so the result would be
[2,3,4,5,6]
i tried to this
result : [],
time : Ember.computed('from', 'to', function() {
this.get('formData.time').forEach(time => {
// formData.time is a service from which i'm getting the array
if (time == this.get('from')) this.get('result').push(time)
this.get('result').push(time)
if (time == this.get('to')) this.get('result').push(time)
})
return this.get('result')
})
but it pushes all the array, i know it's a wrong approach that i'm doing but i couldn't find the proper way to do it
Help Appreciated.
Aucun commentaire:
Enregistrer un commentaire