Angular Filter在指令表达式中不起作用?

时间:2016-05-04 10:02:35

标签: javascript angularjs angularjs-directive

我有指令我在表达式中绑定属性和对象名称。我需要将两个值都转换为小写。我尝试使用过滤器。它不起作用。即使我尝试使用$ filter服务也不行。请帮助任何人实现这一目标。

提前致谢..

指令代码:

 bosAppModule.directive('layoutTableCellControlControlRender',['$compile','$filter', function($compile,$filter){
    var layoutTableCellControlRenderObj={};
    linkFnTableCellControlRender=function(scope, element, attributes) {
        scope.controlData="NOCONTROLDATA";
        scope.kendoOptions={};   
        //scope.field = $filter('lowercase')(scope.field);
    };  
    layoutTableCellControlRenderObj.scope={field:"@",tranobj:"@" };
    layoutTableCellControlRenderObj.restrict='AE';
    layoutTableCellControlRenderObj.replace='true';
    layoutTableCellControlRenderObj.template="<div field={{tablecellcontrol.attributename | lowercase }} tranobj={{tablecellcontrol.objectname | lowercase}}>" +
                                            "</div>";
    layoutTableCellControlRenderObj.link = linkFnTableCellControlRender;

    return layoutTableCellControlRenderObj; 
}]);

1 个答案:

答案 0 :(得分:0)

您应该检查What is the difference between '@' and '=' in directive scope in AngularJS?

双向模型绑定的 中使用该参数 =

layoutTableCellControlRenderObj.scope={field:"=",tranobj:"=" };

点击此处查看此简化演示:http://jsfiddle.net/juanmendez/k6chmnch/