我有这样的选择:
<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;
}
我Id
得到selected value
,但现在我想将此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>
非常感谢帮助!此致
答案 0 :(得分:3)
您应该只在insertar
函数中使用范围变量,而不是重新分配它。像这样:
$scope.insertar = function() {
var selectedId = $scope.selectedID;
if ($scope.catalogoid != null) {...