angular js,将数据作为参数从视图传递到控制器
angular js, passing data as parameter from view to controller
我正在尝试从视图中获取数据,这些数据必须作为函数中的参数传递以填充控制器中的数组。
但是对象 return 我什么都没有,这里是我所做的:
VIEW
<div ng-repeat="cssframework in voce.framewrok">
<input type="checkbox" ng-onchange="AggiornaTotale({{cssframework.costo}})"/>
<span>{{cssframework.name}}........<b>{{cssframework.costo | currency}}</b></span>
</div>
<div class="row">
<h3>TOTALE: {{selectedVoices[0]}}</h3>
</div>
ng-onchange 触发函数 "AggiornaTotale" 并将 cssframework.costo 作为参数传递,控制器中的目标是填充名为 "selectedVoices"
的数组
控制器
$scope.AggiornaTotale = function(param) {
$scope.selectedVoices = [];
this.selectedVoices.push(param);
}
为什么我没有看到 {{selectedVoices[0]}} 更新?
谢谢指教
将ng-onchange
替换为ng-change
改变
ng-onchange="AggiornaTotale({{cssframework.costo}})
至
ng-change="AggiornaTotale({{cssframework.costo}})
和控制器到
$scope.AggiornaTotale = function(param) {
$scope.selectedVoices = [];
$scope.selectedVoices.push(param);
}
我正在尝试从视图中获取数据,这些数据必须作为函数中的参数传递以填充控制器中的数组。 但是对象 return 我什么都没有,这里是我所做的:
VIEW
<div ng-repeat="cssframework in voce.framewrok">
<input type="checkbox" ng-onchange="AggiornaTotale({{cssframework.costo}})"/>
<span>{{cssframework.name}}........<b>{{cssframework.costo | currency}}</b></span>
</div>
<div class="row">
<h3>TOTALE: {{selectedVoices[0]}}</h3>
</div>
ng-onchange 触发函数 "AggiornaTotale" 并将 cssframework.costo 作为参数传递,控制器中的目标是填充名为 "selectedVoices"
的数组控制器
$scope.AggiornaTotale = function(param) {
$scope.selectedVoices = [];
this.selectedVoices.push(param);
}
为什么我没有看到 {{selectedVoices[0]}} 更新? 谢谢指教
将ng-onchange
替换为ng-change
改变
ng-onchange="AggiornaTotale({{cssframework.costo}})
至
ng-change="AggiornaTotale({{cssframework.costo}})
和控制器到
$scope.AggiornaTotale = function(param) {
$scope.selectedVoices = [];
$scope.selectedVoices.push(param);
}