how to implement not with if statement in ember handlebar?
I have a statement like below
{{#if IsValid}}
but i want to know that how can i use if statement with not like below
{{#if not IsValid}}
Simple answers for simple questions:
{{#unless isValid}}
{{/unless}}
Also keep in mind that you can insert an {{else}}
in between an {{#if}}
or {{#unless}}
and the closing tag.
You have many ways of doing that.
1. Use {{unless}}
:
{{#unless isValid}}
...
{{else}}
...
{{/unless}}
2. Use inline-if helper:
{{#if (if isValid false true)}}
...
{{else}}
...
{{/if}}
3. Use ember-truth-helpers addon:
{{#if (not isValid)}}
...
{{else}}
...
{{/if}}
{{#if items.length}}
//Render
{{/if}}
Here items.length .. if it returns some value except null, then only it will enters into the if loop.
NOTE : You can check Boolean values also. In If block
{{#if booleanFloag}}
链接地址: http://www.djcxy.com/p/65808.html
上一篇: 什么是Ember RunLoop?它是如何工作的?
下一篇: 如何实现不与if语句在烬手柄?