2017-07-10 11 views
1

角度とJavascriptに本当に新しい - 私と私はこのような選択角度があります。リファクタリング角度コントローラ

<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> 

をそして私は、コントローラに別の関数内の機能を持っていますが、私はそれらの機能を分離します。

私はこのようなものがあります:

$scope.filtro = function(selected) { 
       $scope.selectedID = selected.ID; 

       $scope.insertar = function() { 
        $scope.selectedID = selected.ID; 
        if ($scope.catalogoid != null) {.... 

をしかし、私はその変更を行うことができますどのように、オープン$scope.insertar前1 $scope.filtroを閉じ、$scope.filtro$scope.selectedIDを呼び出し、$scope.insertarに呼びたいですか? Sajeetharanコメントとしてよろしく

UPDATE

私は

$scope.filtro = function (selected) { 
      $scope.selectedID = selected.ID; 
      $scope.insertar(selected); 
     } 

     $scope.insertar = function (selected) { 
        $scope.selectedID = selected.ID; 
        if ($scope.catalogoid != null) { 

を行うしかし、私はselected is udefined取得。誰も助けてくれますか?あなただけの最初の内側の第2の機能を呼び出すことができます

答えて

1

$scope.filtro = function(selected) { 
$scope.selectedID = selected.ID; 
$scope.insertar(selected); 
} 
$scope.insertar = function(selected) { 
$scope.selectedID = selected.ID; 
} 
+0

私はそれを行うが、私はただのgettin選択が – Ledwing

+0

トライ更新の$ scope.insertar =機能(選択)に定義されていません{ – Sajeetharan

+0

は未定義得続けます:/ – Ledwing

関連する問題