UI-SELECT 绑定到数组中的 controller.js?
UI-SELECT binding to controller.js in Array?
首先感谢您的阅读。
我是这门语言的新手。
我正在尝试使用 UI-SELECT 并将数据绑定到 controller.js 以保存到数据库中。
我知道 UI-SELECT 应该以 "A.selected" 的方式与 ng-model 一起使用。
我搜索了一些帮助,但找不到如何使以下数组样式的代码正常工作。
[HTML 与 UI-Select]
<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>
[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?
})
我想我快到了,但它只返回 "array" 标志。
我知道这可能很容易,但我迷路了将近一整天。
任何建议将不胜感激,希望这个问题对其他人也有帮助。 :)
谢谢你,祝你有个愉快的一天!
ui-select
将 return 和 ng-model
作为对象而不是数组。您可以使用下面示例中所示的 .
语法并访问所需的变量。
$scope.fetch = function() {
alert($scope.project_customer_company.selected.customer_company_name);
alert($scope.project_customer_company.selected.customer_company_ceo);
}
在上面的代码中,您可以看到首先我们访问对象 $scope.project_customer_company
的 selected
属性,然后使用另一个 .
我们访问各个属性customer_company_name
和 customer_company_ceo
如果您遇到任何问题,请告诉我!
首先感谢您的阅读。 我是这门语言的新手。
我正在尝试使用 UI-SELECT 并将数据绑定到 controller.js 以保存到数据库中。
我知道 UI-SELECT 应该以 "A.selected" 的方式与 ng-model 一起使用。
我搜索了一些帮助,但找不到如何使以下数组样式的代码正常工作。
[HTML 与 UI-Select]
<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>
[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?
})
我想我快到了,但它只返回 "array" 标志。
我知道这可能很容易,但我迷路了将近一整天。
任何建议将不胜感激,希望这个问题对其他人也有帮助。 :)
谢谢你,祝你有个愉快的一天!
ui-select
将 return 和 ng-model
作为对象而不是数组。您可以使用下面示例中所示的 .
语法并访问所需的变量。
$scope.fetch = function() {
alert($scope.project_customer_company.selected.customer_company_name);
alert($scope.project_customer_company.selected.customer_company_ceo);
}
在上面的代码中,您可以看到首先我们访问对象 $scope.project_customer_company
的 selected
属性,然后使用另一个 .
我们访问各个属性customer_company_name
和 customer_company_ceo
如果您遇到任何问题,请告诉我!