0

I need to display only name from request in my form, can't figure out how to do it. I'm just starting with js, need help.

I have tried this {{ request.name }} but doesn't work. {{request}} shows me full data.

const app = new Vue({
      el:'#valuation-request',
      data() {
        return {
          step:1,
          request:{
            name:null,
            industry:'{{ $company->industry }}',
            valuation_date:null,
            similar_comp:null,
            total_raised:null,
            sales_transactions:null
          }
        }
      },
      methods:{
        prev() {
          this.step--;
        },
        next() {
          this.step++;
        }


      }
    });
2
  • 1
    name is null so it's not going to print anything. Are you setting it's value somewhere else? Commented Jun 28, 2018 at 23:48
  • I'm setting it in form <input type="text" class="uk-input" name="name" v-model="request.name" id="name" placeholder="e.g. John Doe" required> Commented Jun 29, 2018 at 2:09

1 Answer 1

3

If name has a value, it should display as you wrote it. If it's null, nothing will be displayed.

const app = new Vue({
      el:'#valuation-request',
      data() {
        return {
          step:1,
          request:{
            name: null,
            industry:'{{ $company->industry }}',
            valuation_date:null,
            similar_comp:null,
            total_raised:null,
            sales_transactions:null
          }
        }
      },
      methods:{
        prev() {
          this.step--;
        },
        next() {
          this.step++;
        }


      }
    });
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.16/vue.js"></script>
<div id="valuation-request">
  {{request.name}}
  <hr>
  Name: <input type="text" class="uk-input" name="name" v-model="request.name" id="name" placeholder="e.g. John Doe" required>
</div>

Sign up to request clarification or add additional context in comments.

3 Comments

I'm setting name in form <input type="text" class="uk-input" name="name" v-model="request.name" id="name" placeholder="e.g. John Doe" required>
@PhilippNoris I don't see the issue. Note the change to the example above.
I found the problem :) Thanks!

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.