如何从$ scope。$ on返回一些值到$ scope。$ emit [英] How to return some value from $scope.$on to $scope.$emit

查看:246
本文介绍了如何从$ scope。$ on返回一些值到$ scope。$ emit的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

评论的部分将位于$ scope。$ on。我需要将选项返回到我保留$ scope的位置。$ emit。请帮助!!!



即使有任何其他方法可以做到这一点,请告诉我。此代码也在角度自定义指令下,在许多地方使用,所以我不能保留注释代码。它必须从外面的某个地方传递。



我尝试过:



 if(gridConfig.Batch){
gridOption.dataSource.transport [parameterMap] = function(options,operation){
var data = {
选项:选项,
操作:操作
};
$ scope。$ emit('parameterMap',data);
// if(operation!==read&& options.models){
// angular.forEach(options.models,function(value){
// value .MfgDt = kendo.toString(value.MfgDt,s);
// value.ExpDt = kendo.toString(value.ExpDt,s);
// value.ProductType = value .ProductType.Id;
//})
//返回选项;
//}
}
}

解决方案

范围。

上。我需要将选项返回到我保留的位置


范围。


The commented part will lie under $scope.$on. I need to return options to the place where I have kept $scope.$emit. Please HELP!!!

Even if there is any other way to do this then let me know. Also this code is under angular custom directive which is being used in many places so I can't keep the commented code there. It has to be passed from somewhere outside.

What I have tried:

if (gridConfig.Batch) {
                gridOption.dataSource.transport["parameterMap"] = function (options, operation) {
                    var data = {
                        options: options,
                        operation: operation
                    };
                    $scope.$emit('parameterMap', data);
                    //if (operation !== "read" && options.models) {
                    //    angular.forEach(options.models, function (value) {
                    //        value.MfgDt = kendo.toString(value.MfgDt, "s");
                    //        value.ExpDt = kendo.toString(value.ExpDt, "s");
                    //        value.ProductType = value.ProductType.Id;
                    //    })
                    //    return options;
                    //}
                }
            }

解决方案

scope.


on. I need to return options to the place where I have kept


scope.


这篇关于如何从$ scope。$ on返回一些值到$ scope。$ emit的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆