简体   繁体   中英

passing scope model data to controller

With angular, I have the following setup on my view:

 <div class="sli1"
 ng-init="test=[10,20,30,40,50]"

 <div class="sli2"
 ng-init="test2=[10,20,30,40,50]"

I'm trying to pass the ng-init data model back to the controller to pick up as:

$scope.data1= $scope.test;
$scope.data2= $scope.test2;

Where I use it further down in an array:

$scope.sli['test'][0];
$scope.sli['test'][1];
$scope.sli['test'][2];
$scope.sli['test'][3];

However not sure what I've missed out.

我的建议是更多地研究angularjs的工作方式,在视图上初始化数据并传递给控制器​​以对其进行处理是非常错误的,尤其是如果您对数据进行处理

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM