[英]Pass variable from one function to another function
我有这样的选择:
<select class="form-control" ng-hide="Catalogos.length==0" ng-change="filtro(selected)" ng-model="selected" ng-options="item.Nombre for item in Catalogos "></select>
从那里我得到这样的函数中的selected value
:
$scope.filtro = function(selected) {
$scope.selectedID = selected.ID;
}
在那里,我获得了selected value
Id
,但是现在我想将此parameter
发送给另一个函数,例如:
$scope.insertar = function(selected) {
$scope.selectedID = selected.ID;
if ($scope.catalogoid != null) {...
但是selected
总是来不定的
注意: $scope.insertar
在我单击提交按钮时触发
<button type="submit" class="btn blue" ng-click="insertar();">Aceptar</button>
帮助非常感谢! 问候
您应该只在insertar
函数中使用scope变量,而不要重新分配它。 像这样:
$scope.insertar = function() {
var selectedId = $scope.selectedID;
if ($scope.catalogoid != null) {...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.