Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

215
Views
Add default value to input field Angular2

I'm trying to build an angular 2 application, my problem is that i want to give a default value for an input and make it disabled i tried this but it doesn't work.

<div class="form-group">
    <label for="input01">UUID</label>
    <input class="form-control form-control-rounded" id="input01" style="width:600px;margin-left:60px" type="text" [(ngModel)]="beacon.uuid" value="{{uuid}}" name="uuid" disabled>
  </div>

Any solution?

about 4 years ago · Santiago Trujillo
3 answers
Answer question

0

If you want to give a default value without two-way binding, use [value]:

<div class="form-group">
  <label for="input01">UUID</label>
  <input id="input01" type="text" [value]="beacon.uuid" class="form-control form-control-rounded" name="uuid" disabled>
</div>
about 4 years ago · Santiago Trujillo Report

0

Your template:

<div class="form-group">
    <label for="input01">UUID</label>
    <input class="form-control form-control-rounded" id="input01" style="width:600px;margin-left:60px" type="text" [(ngModel)]="beacon.uuid" name="uuid" [disabled]="true">
  </div>

In your component:

ngOnInit() {
  beacon.uuid = "my default value"
}
about 4 years ago · Santiago Trujillo Report

0

Try removing the value from input

<div class="form-group">
    <label for="input01">UUID</label>
    <input class="form-control form-control-rounded" id="input01" type="text" [(ngModel)]="beacon.uuid" name="uuid" disabled>
</div>

Otherwise it will be a conflict between your style and disabled attribute

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!