I am trying to make an UPDATE window.
If I bring the data with $scope.project_data, it works for the INPUT TYPE=”TEXT”. But, not for the UI-Select.
I think I have to make some changes to UI-SELECT-MATCH. But, I am not sure how to bind the SQL data to UI-SELECT-MATCH on the instance when the window is brought up.
[HTML]
<!-- This works. -->
<input type = "text" class = "form-control" ng-model = "project_data.project_title" id = "project_title" required/>
<!-- This does NOT work. -->
<ui-select ng-model = "project_customer_company.selected" theme="bootstrap" id="project_customer_company">
<ui-select-match></ui-select-match>
<ui-select-choices repeat="customer in customers | filter: $select.search">
<div ng-bind-html="customer.customer_company_name | highlight: $select.search"></div>
<div ng-bind-html="customer.customer_company_ceo | highlight: $select.search"></div>
</ui-select-choices>
</ui-select>
[Controller.JS]
//This is to bring data from SQL table.
$http.post("../crud/projects_read.php", {
})
.then(function(response){
$scope.projects = response.data;
$scope.project_data = $scope.projects[$stateParams.id];
});
$scope.updateData = function(project_id){
$http.post("../crud/projects_update.php",{
project_id : $scope.project_data.project_id,
project_title : $scope.project_data.project_title,
project_customer_company : $scope.project_customer_company.selected.customer_company_name
})
If I do console.log(project_customer_company);, then it appears good from the SQL.
When I run the application, the UI-Select-Match won’t bring the data nor update it.
You may wonder why I didn’t put “project_data.” in front of anything in UI-SELECT, but I tried. I left it out so it looks better for you the experts to check.
In conclusion, it is like this:
Step 1. The project_data bring the data from the SQL. (it works fine)
Step 2. It should bind to the UI-Select-Match when the window for update is brought up.
Step 3. Other UI-Select-Choices comes from other array (it works fine)
So the problem is the Step 2. Please help me on this issue!
I hope this helps the others as well.
Thank you in advance!!
Source: AngularJS
from Angular Questions https://angularquestions.com/2017/10/20/ui-select-match-value-for-binding-when-performing-update/
via @lzomedia #developer #freelance #web #lzomedia.com
No comments:
Post a Comment