您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

$ on和$广播角度

$ on和$广播角度

如果要$broadcast使用$rootScope

$scope.startScanner = function() {

    $rootScope.$broadcast('scanner-started');
}

然后使用$scope您控制器的接收:

$scope.$on('scanner-started', function(event, args) {

    // do what you want to do
});

如果愿意,可以在以下情况下传递参数$broadcast

$rootScope.$broadcast('scanner-started', { any: {} });

然后接收它们:

$scope.$on('scanner-started', function(event, args) {

    var anyThing = args.any;
    // do what you want to do
});
其他 2022/1/1 18:13:43 有548人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶