Angularjs UI-SELECT绑定到数组中的controller.js?

Angularjs UI-SELECT绑定到数组中的controller.js?,angularjs,ui-select,Angularjs,Ui Select,首先,感谢您的阅读。 我不熟悉这门语言 我正在尝试使用UI-SELECT并将数据绑定到controller.js以保存到数据库中 我知道UI-SELECT应该以“A.selected”的方式与ng模型一起使用 我搜索了一些帮助,但找不到如何使下面的代码以数组样式工作 [带用户界面的HTML选择] <ui-select ng-model = "project_customer_company.selected" theme="bootstrap"> <ui-select-ma

首先,感谢您的阅读。 我不熟悉这门语言

我正在尝试使用UI-SELECT并将数据绑定到controller.js以保存到数据库中

我知道UI-SELECT应该以“A.selected”的方式与ng模型一起使用

我搜索了一些帮助,但找不到如何使下面的代码以数组样式工作

[带用户界面的HTML选择]

<ui-select ng-model = "project_customer_company.selected" theme="bootstrap">
  <ui-select-match placeholder="">
    {{$select.selected.customer_company_name}}</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>

{{$select.selected.customer\u company\u name}

[Controller.js]

$scope.project_customer_company = {};

$http.post("../crud/projects_insert.php", {
  project_title : $scope.project_title,
  project_customer_company : $scope.project_customer_company // coming from <UI-SELECT>, and this has to be changed like in array style but how?
  })
$scope.project\u customer\u company={};
$http.post(“../crud/projects\u insert.php”{
项目名称:$scope.project\u title,
project\u customer\u company:$scope.project\u customer\u company//来自,必须像数组样式一样进行更改,但如何更改?
})
我想我快到了,但它只返回“数组”符号

我知道这可能很容易,但我几乎迷路了一整天

如果您有任何建议,我们将不胜感激,并希望此问题对其他人也有帮助。:)


谢谢你,祝你今天愉快

ui选择
将把
ng模型
作为对象而不是数组返回。您可以使用如下示例所示的
语法,并访问所需的变量

  $scope.fetch = function() {
    alert($scope.project_customer_company.selected.customer_company_name);
    alert($scope.project_customer_company.selected.customer_company_ceo);
  }
在上面的代码中,您可以看到,首先我们访问对象
$scope.project\u customer\u company
所选
属性,然后使用另一个
访问单个属性
customer\u company\u name
customer\u company\u ceo


如果您遇到任何问题,请告诉我

谢谢你的解释!希望这能帮助其他在UI-SELECT绑定中挣扎的人!祝您今天过得愉快!