第一控制器:
$rootScope.$broadcast("CallParentMethod", {});
第二名管制员:
$rootScope.$on("CallParentMethod", function() {
$scope.getUserDetails();
})
$scope.getUserDetails = function() {
HttpService.get("/customer/" + nationalId).then(function(resp) {
if (resp.status == 'success') {
console.log(resp.result)
$rootScope.county_name = angular.copy(resp.result.county)
$rootScope.campaign_name = angular.copy(resp.result.campaign)
console.log($rootScope.campaign_name)
}
});
};
答案 0 :(得分:0)
有$scopes
混合
此事件被解雇
$rootScope.$broadcast("CallParentMethod", {});
因此,您应该在$ $范围内收听此活动,但您正在$rootScope
$rootScope.$on("CallParentMethod", function() {
$scope.getUserDetails();
})
您可能希望在定义getUserDetails()
的同一范围内听取它
$scope.$on("CallParentMethod", function() {
$scope.getUserDetails();
})
另一个提示:如果您不需要传递任何参数,则可以在{}
$broadcasting
$rootScope.$broadcast("CallParentMethod")