I am having trouble storing textbox values in my 'Values' variable. When I enter values in the textboxes, it seems to be getting the hard-coded values instead. Can someone please help me with this AngularJS issue as I am new to it? Here is the code snippet:
$scope.form = {
site_name: 'Site name',
street_address: 'Street address',
city: 'City',
state: 'State',
country: 'Country',
zip_code: 'Zip Code',
phone_number: 'Phone Number'
};
$scope.addRow = function() {
$scope.i++;
$scope.array = [];
for(var i = 0; i < $scope.i; i++) {
$scope.array.push(i);
}
}
var checkprofile = $scope.Profile.id;
$(".alert").hide();
$scope.updateProfile = function () {
console.log('updateProfile');
console.log($scope.form);
$scope.Profile.addresses.push($scope.form);
$scope.tempObject = {
full_name: $scope.Profile.full_name,
mobile_number: $scope.Profile.mobile_number,
company_name: $scope.Profile.company_name,
designation: $scope.Profile.designation,
addresses: $scope.Profile.addresses,
payment_info: $scope.Profile.payment_info
};
$http.put(properties.customerupdate_path + "/" + checkprofile, $scope.tempObject).success(function (response) {
// window.location.href = '/customerprofile';
});
}
When I click a button after entering values in the textboxes, below code does not retrieve data from the textboxes but returns the previous hardcoded values:
$scope.updateProfile = function () {
console.log('updateProfile');
console.log($scope.Values);
}
//result --> [Object {site_name="Site name", street_address="Street address", city="City", more...}]
}
HTML:
<tr ng-repeat="lines in array">
<td><input type="text" class="form-control" id="inputDefault" ng-model='Values.site_name' name='site_name'></td>
<td><input type="text" class="form-control" id="inputDefault" ng-model='Values.street_address' name='street_address'></td>
<td><input type="text" class="form-control" id="inputDefault" ng-model='Values.city' name='city'></td>
<td><input type="text" class="form-control" id="inputDefault" ng-model='Values.state' name='state'></td>
<td><input type="text" class="form-control" id="inputDefault" ng-model='Values.country' name='country'></td>
<td><input type="text" class="form-control" id="inputDefault" ng-model='Values.zip_code' name='zip_code'></td>
<td><input type="text" class="form-control" id="inputDefault" ng-model='Values.phone_number' name='phone_number'></td>
</tr>
Update Profile