从页面将参数传递给Angular控制器

时间:2018-12-05 16:08:16

标签: angularjs parameters controller angular2-directives

我有一个包含两个控制器的网页,第一个控制器列出广告 每个广告都有AId,它会使用{{x.AId}}显示。在Next Div中获取广告详细信息如何将{{x.AId}}传递到同一页面上的另一个控制器?

    var app = angular.module("myModule", ['angularUtils.directives.dirPagination']);

    //This Gets all the Classifieds
    app.controller("GetClassifiedDetails", function ($scope, $http) {

        $http({
            url: "assets/services/MasterWebService.asmx/GetAdsList",
            method: "GET"
        }).then(function (response) {
            console.log(response.data);
            $scope.ListClassifieds = response.data;
            $scope.TotalClassifieds = response.data.length;
        });

    });


    app.controller("GetAdsVisitedStats", function ($scope, $http) {


        $http({
            url: "assets/services/MasterWebService.asmx/spAdsVisitStatis",
            method: "GET",params: { AId }
        }).then(function (response) {
            console.log(response.data);
            $scope.ListAdsVistedStats = response.data;
            $scope.TotalAdsVisited = response.data.length;
        });

    });

0 个答案:

没有答案