2017-02-18 4 views
0

mit dieser meiner vue istgehen Sie zu einem Laravel Controller vue js Daten

new Vue({ 
       el: '#notificationMenu', 
       data: { 
       showModal: false, 
       patients: [], 
       duepatients: [] 
       }, 
       created: function(){ 
        this.getPatients(); 
        this.addUsers(); 
       }, 
       methods: { 
        getPatients: function(){ 
          $.getJSON("{{route('api_patients')}}", function(patients){ 
          this.patients = patients; 
         }.bind(this)); 
         setTimeout(this.getPatients, 1000); 
        }, 
        addUsers: function(){ 
         this.$http.get('/govaccine/addUsers', '').then((response) => { 

         }, (response) => { 
         this.formErrors = response.data; 
         }); 

         setTimeout(this.addUsers, 10000);       
        },sendSMS: function(val){ 

         $.getJSON('sendsms/' + val,function(duepatient){ 
          this.duepatients = duepatient; 
         }.bind(this)); 

        } 
       } 

      }); 

und das ist mein html

<ul class="notifications-list" v-for="patient in patients"> 
         <li class="item no-data">You don't have notifications</li> 

           <!-- use the modal component, pass in the prop --> 
          <modal v-if="showModal" @close="showModal = false"> 
          <!-- 
           you can use custom content here to overwrite 
           default content 
          --> 
          <h3 slot="header">custom header</h3> 
          </modal> 
          <a v-on:click="sendSMS(patient.due_date)"> 
           <li class="item js-item " data-id="5" > 
            <div class="details"> 
             <strong>@{{ patient.total}} patients</strong> are due for immunization on @{{patient.due_date}} 
             <span class="date">{{-- @{{patient.created_at}} --}}</span> 

            </div> 
            <button type="button" class="button-default button-dismiss js-dismiss">×</button> 
           </li> 
          </a> 
        </ul> 

Wenn ich Schleife durch vue js Daten mit v-for, wie ich die Daten passieren kann Jede Schleife in {{route ('patient.show', Parameter)}}, so dass ich einen Parameter darauf setzen kann.

oder gibt es trotzdem, um zum Controller zu gehen und auf die andere Seite zu gehen?

Antwort

0

ja sollten Sie Router-Link verwenden. vollständiges Beispiel here. Wenn ich deine Frage falsch beantworte, sag es mir einfach.