Angular js在另一个函数中使用来自resolve的数据

时间:2016-09-21 17:48:52

标签: angularjs

我还没有角色。我正在尝试使用从我的数据库中从此函数myContributionPage()中提取的数据,并在我的myNo函数中使用id值但未定义myContributionPage.id

(function(angular, $, _) {

    angular.module('pcp').config(function($routeProvider) {

        $routeProvider.when('/pcp', {
            controller: 'PcppcpCtlr',
            templateUrl: '~/pcp/pcpCtlr.html',

            // If you need to look up data when opening the page, list it out
            // under "resolve".
            resolve: {
                myPcp: function(crmApi) {
                    return crmApi('Pcp', 'get', '');
                },
                myContributionPage: function(crmApi) {
                    return crmApi('Contribution_page', 'get', '');
                },
                myNo: function(crmApi) {
                    return  crmApi('Contribution', 'getcount',{ contribution_page_id: Contribution_page.id});//my problem not working
                }
            }
        });
    });

    // The controller uses *injection*. This default injects a few things:
    //   $scope -- This is the set of variables shared between JS and HTML.
    //   crmApi, crmStatus, crmUiHelp -- These are services provided by civicrm-core.
    //   myContact -- The current contact, defined above in config().
    angular.module('pcp').controller('PcppcpCtlr', function($scope, crmApi, crmStatus, crmUiHelp,myPcp,myContributionPage,myNo) {

        // The ts() and hs() functions help load strings for this module.
        var ts = $scope.ts = CRM.ts('pcp');

        var hs = $scope.hs = crmUiHelp({file: 'CRM/pcp/pcpCtlr'}); // See: templates/CRM/pcp/pcpCtlr.hlp

        // We have myContact available in JS. We also want to reference it in HTML.
        $scope.myPcp = myPcp.values;
        //$scope.myContribution = myContribution;
        $scope.myContributionPage = myContributionPage.values;
        $scope.myNo=myNo;
    });

})(angular, CRM.$, CRM._);

0 个答案:

没有答案