html - If condition in angularjs for ng-grid -


I am working on the angularjs page. I have the following code.

  columnDefs: [{field: 'dt', displayName: 'date', width: '***', cellfilter: 'date: \ "DD-MMM -yyy \' '} , {Field: 'dt', displayName: 'time', width: '***', cellfilter: 'date: \ "HH: mm: SS \"'}, {field: 'RL', 'display name: 'Importance', width: '80px'}, {field: 'av', display name: 'event', width: '******'}, {field: 'task', displayName: 'ac', width : '**'}, {field: 'ftt', display_name: 'fc', width: '**'}, {field: 'fl', sortable: true, displayname: 'country', cell Emplet: '& Lt; Div class = "ngCellText" ng-class = "col.colIndex ()" & gt; & Lt; Span ng-cell-text & gt; Img class = "flag" src = "c: / country_images / 1 jpg}" & lt; / Img & gt; & Lt; / Div & gt; & Lt; / Div & gt; Width: '80px'}, {field: 'pre', displayName: 'Pv', width: '**'}]   

I value rl Based on the project directory "C: / CountryImages" , we want to display an image (field: FL): RL values ​​are restricted to "H" "L" and "M" . Therefore, if there is value of rl = "h" then it should get C: country country / 1.jpg and if RL = "L" then C: / country image / 3.jpg

thanks in advance :)

Create a filter that carries your mapping from image to image path, and its IMG ng-src binding expression Apply on, something like 'country', cell template: '& lt; Like {class: 'fl', sortable: true, displayName} & lt; div class = "ngCellText" ng-class = "col.colIndex ()"

  Span ng-cell-text & gt; & Lt; Img class = "flag" ng- src = "row.getProperty (\ 'rl \') | imagefilter" & lt; / Img & gt; & Lt; / Span & gt; & Lt; / Div> ', Width:' 80px '},   

The filter will look like

  angular.module (' myApp ') .Filter (' imagefilter ', function ( } {Return Function (RL) {If (RL === 'L') Returns 'C: / County Images / 3.jpg' // Other Mapping}}    

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -