How to implement not with if statement in Ember Handlebars?

后端 未结 6 1685
故里飘歌
故里飘歌 2021-01-30 04:34

I have a statement like this:

{{#if IsValid}}

I want to know how I can use a negative if statement that would look like that:

6条回答
  •  醉酒成梦
    2021-01-30 05:19

    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}}
    

提交回复
热议问题