Warning: Novice Programmer! I have my ng-grid
警告:新手程序员!我有我ng-grid
columnDefs: [
{field:'', displayName:'Article', cellTemplate: TitleColumn2, width: '300px'},...
I'm using a cellTemplate because I don't want to throw the conditional logic in the clean grid.
我使用的是cellTemplate,因为我不想把条件逻辑放在干净的网格中。
var TitleColumn2='<div class="ngCellText"><span ng-show="row.entity[\'url\']"><a href="{{row.entity[\'url\']}}">{{row.entity[\'title\']}}</a></span></div>';
In my object the url value be blank or it may have value. If it's blank I just want to display the text value but if it has a value I want to display the etc... I seem to have the show if there's a value bit but how do I show just the title if there's no value (url= "").
在我的对象中,url值是空的,或者它可能有值。如果它是空的,我只想显示文本值,但是如果它有一个值,我想显示……如果有一个值位,我似乎有这个显示,但是如果没有值(url= "),我如何显示标题。
So my question surrounds performing equations on what to display vs. performing a conditional class statement. I found answers for conditional classes but for some reason this doesn't seem to work here. Sorry if I'm overlooking the obvious. It would be nice to see an answer there shows the difference between a conditional if/then for a class and a conditional if/then for a span text display. Please....
所以我的问题是,在执行关于显示什么和执行条件类语句的方程时。我找到了条件类的答案,但出于某种原因,这在这里似乎行不通。对不起,我忽略了显而易见的问题。很高兴看到这里的答案显示了类的条件if/then和span文本显示的条件if/then之间的区别。请....
1 个解决方案
#1
2
I answered this myself because if there are other novices out there like myself then maybe this will help you.
我自己回答了这个问题,因为如果有其他像我这样的新手,那么这可能会对你有所帮助。
The answer was obvious in the end. I was too hung up on trying to grapple with cellTemplate
that I missed the fundamental ng
syntax.
答案最终是显而易见的。我太沉迷于尝试使用cellTemplate而忽略了基本的ng语法。
Please comment if anyone disagrees with this or has a better suggestion.
如果有人不同意或有更好的建议,请评论。
var TitleColumn2='<div class="ngCellText"><span ng- show="row.entity[\'url\']">
<a href="{{row.entity[\'url\']}}">{{row.entity[\'title\']}}</a></span>
<span ng-show="!row.entity[\'url\']">{{row.entity[\'title\']}}</span></div>'
#1
2
I answered this myself because if there are other novices out there like myself then maybe this will help you.
我自己回答了这个问题,因为如果有其他像我这样的新手,那么这可能会对你有所帮助。
The answer was obvious in the end. I was too hung up on trying to grapple with cellTemplate
that I missed the fundamental ng
syntax.
答案最终是显而易见的。我太沉迷于尝试使用cellTemplate而忽略了基本的ng语法。
Please comment if anyone disagrees with this or has a better suggestion.
如果有人不同意或有更好的建议,请评论。
var TitleColumn2='<div class="ngCellText"><span ng- show="row.entity[\'url\']">
<a href="{{row.entity[\'url\']}}">{{row.entity[\'title\']}}</a></span>
<span ng-show="!row.entity[\'url\']">{{row.entity[\'title\']}}</span></div>'