<div ng-controller="myctr">
<div ng-repeat="model in models">
Value: {{model.name}}
<input ng-model="model.name">
</div>
<button type="submit" class="button button-balanced" ng-click="saveAllValues()"> </button>
</div>
$http.put('http://192.168.1.55:8000/api/ClickEmployeeNumgoal/' +$sessionStorage.ClickEmployeeNum , $sessionStorage)
.success(function (response){
$scope.models = [] ;
$scope.models = response;
})
如何在角度控制器中获取ng-model values []
$scope.empgoalNumber = [];
$scope.saveAllValues = function(req,res)
{
$scope.empgoalNumber.push($scope.model.name);
}
错误是名称未定义......如何定义全局数组以访问ng-repeat中的所有ng-model ???
答案 0 :(得分:0)
您应该使用全局(或范围级别)变量。
$scope.ngmodelvalue = [];
$scope.saveAllValues = function(res, req) {
$scope.ngmodelvalue.push($scope.model.name);
}
您可以使用$scope.ngmodelvalue
获取值。