Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ng使用angularjs设置范围单击_Angularjs - Fatal编程技术网

ng使用angularjs设置范围单击

ng使用angularjs设置范围单击,angularjs,Angularjs,我使用AngularJS实现了ng click,但它似乎不起作用,我想将ng repeat中选定的客户发送到我的视图中 我的代码: var-app=angular.module(“GestiawebApp”,[]); app.controller(“CustomerController”,函数($scope,$http){ $http.get('/api/eccustomer').success(函数(数据、状态、标题、配置){ $scope.customers=数据; }); $scope.

我使用AngularJS实现了
ng click
,但它似乎不起作用,我想将
ng repeat
中选定的客户发送到我的视图中

我的代码:

var-app=angular.module(“GestiawebApp”,[]);
app.controller(“CustomerController”,函数($scope,$http){
$http.get('/api/eccustomer').success(函数(数据、状态、标题、配置){
$scope.customers=数据;
});
$scope.chooseCustomer=功能(客户){
$scope.choosingCustomer=客户;
};
});

  • {{customer.firstname}
{{choosingCustomer.firstname}

只需使用

ng-click="$parent.chooseCustomer(customer)"

因为在ng内重复您的范围更改

有控制台错误吗?没有什么。。。
ng repeat
工作正常,我可以在
chooseCustomer
功能中获取
customer
。\n好的,
customer
中是否有
firstname
属性?是的,我在
customer
;)但我发现了问题,作用域正在发送另一个控制器;)它也不起作用,但我在考虑控制器,我的
在另一个控制器内,这不是同一个控制器,如何将客户传递到另一个控制器?看这个问题: