[英]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.