Sign up ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free.

In html we use to write like this <input type="text" value="8">. I am facing two problems while I am doing it using angular js tags.

  1. I want to set some value which I am taking from database like value=8.

  2. And I am using one drop down in this form. I want to auto select some value which is set in database.

<form id="attendanceSheet" name="attendanceSheet" ng-submit="fillUpTimeSheet(attendanceSheet.$valid)" >                 
    <table ng-table="tableParams" class="table">
        <tr ng-repeat="resource in resources">                          
            <td data-title="'Working Hours'" style="text-align:center" ng-if="resource.isBillable == 1">{{resource.billable_hours}}h&nbsp;&nbsp;<input type="number" style="width: 55px;" min="0" max="8" ng-init="timeSheet[$index] = {}" ng-model="timeSheet[$index].billableHour" required></td>                         
            <td data-title="'Non Billable Resource'" style="text-align:center" ng-if="resource.isBillable == 1"><select data-ng-options="o.resource_name for o in nonBillableResources" style="width: 150px;" ng-model="timeSheet[$index].nonBillableResource"></select></td>
        </tr>
    </table>
</form>

To set the value I tried like this .. value="resource.id" OR ng-init="timeSheet[$index] = {resource.id}"

Please I need help.

share|improve this question
    
angular binds the entered/selected value to a model, using ng-model. It does that in both directions. So, simply make sure that the value referenced by ng-model contains what you want to display/select in the input/select. Don't use the value field of the input. –  JB Nizet Oct 19 '14 at 8:56
    
Ok.. I will try and let you know –  Sariban D'Cl Oct 19 '14 at 9:49
    
I have used ng-model="resource.billable_hours" so, now I am getting the value in text box. But when I submit the form I get null object. –  Sariban D'Cl Oct 19 '14 at 10:56
    
I am using ng-repeat="resource in resources" because many records are available in db. When I remove ng-repeat="resource in resources" then I get the value after submiting the form. –  Sariban D'Cl Oct 19 '14 at 11:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.