在多个函数中调用变量javascript角度控制器

时间:2015-02-09 06:08:29

标签: javascript angularjs

我有以下控制器文件

angular.module('IpadAppApp')
    .controller('Mortgage_LoanCtrl', function ($location, $scope, $http, $modal) {

    var loans, loandatarray, loandata, params, passParams;

    $scope.paramsData = function() {
         params = {
           land_type: (!!filter.loan_type.value? filter.loan_type.value : 'Residential'),
         property: (!!filter.property_value.value? filter.property_value.value : 500000),
         finance_margin: (!!filter.margin_finance.value? filter.margin_finance.value : 90),
         tenure: (!!filter.tenure.value? filter.tenure.value : 20),
         rate_type: (!!filter.rate_type.value? filter.rate_type.value : 'Floating and fixed interest'),
         flexi: (!!filter.full_non_flexi.value? filter.full_non_flexi.value : 'Full flexi and non full flexi loan'),
         islamic: (!!filter.conventional_islamic.value? filter.conventional_islamic.value : 'Islamic and Conventional'),
         sort_by: $scope.getActiveColumn('table.packages'),
         sort_direction: $scope.getSortDirection('table.packages'),
         lock_in: (!!filter.lock_period.value? filter.lock_period.value : 'Show all')
       };
       return params;
     };

   $scope.homeloandata = function() {

        $scope.paramsData();
        passParams = params;
        passParams = JSON.stringify(passParams).replace(/:/g,'=').replace(/"/g,'').replace(/,/g,'&').replace(/{/g,'').replace(/}/g,'').replace(/ /g,'+');   
    };

   $scope.submit_info = function() {
     console.log(passParams);
   };
});

问题是当我在homeloandata中要求passParams变量时它完全返回。

但是当我在submit_info中请求数据时,它返回undefined。

有谁知道为什么?我想在submit_info中的passParams中返回数据。

0 个答案:

没有答案