javascript - AngularJS - check for null item in ng-repeat - Stack Overflow

I am using ng-repeat to display rows in a table and when two items are not null I want to display true

I am using ng-repeat to display rows in a table and when two items are not null I want to display true in HTML. I've searched but I can't find an expression or ng directive.

<table class="table table-bordered table-striped">
                <thead>
                    <tr>
                        <th>Account Enabled?</th>
                        <th>Username</th>
                        <th>Date Registered</th>
                        <th>User Displayname</th>
                        <th>Password Reset?</th>
                        <th>Password Valid To</th>
                        <th>Log On Count</th>
                        <th>Last Logged On</th>
                        <th>Is Primary Account?</th>
                        <th></th>
                    </tr>
                </thead>
                <tbody>
                    <tr data-ng-repeat="item in onlineAccounts.CommunicationMethods">
                        <td>
                            {{item.IsEnabled}}
                        </td>
                        <td>
                            {{item.UserName}}
                        </td>
                        <td>
                            {{item.CreatedOn}}
                        </td>
                        <td>
                            {{item.OnlineDisplayName}}
                        </td>
                        <td>
                            {{}}
                        </td>
                        <td>
                            <div ng-if="item.PasswordResetTokenValidTo != null &&  item.PasswordResetTokenValidTo != null">True</div>
                            <div ng-if="item.PasswordResetTokenValidTo == null item.PasswordResetTokenValidTo == null">False</div>
                        </td>
                        <td>
                            {{item.LogOnCount}}
                        </td>
                        <td>
                            {{item.LastLoggedOn}}
                        </td>
                    <td>
                            {{item.IsDefault}}
                    </td>
                </tr>
                </tbody>
            </table>

This is the line I want to change:

  <div ng-if="item.PasswordResetTokenValidTo != null &&  item.PasswordResetTokenValidTo != null">True</div>
                            <div ng-if="item.PasswordResetTokenValidTo == null item.PasswordResetTokenValidTo == null">False</div>

I get the error:

Error: [$parse:syntax] Syntax Error: Token 'item' is an unexpected token at column 40 of the expression [item.PasswordResetTokenValidTo == null item.PasswordResetTokenValidTo == null] starting at [item.PasswordResetTokenValidTo == null].

Is there any angular guru that can help me out?

I am using ng-repeat to display rows in a table and when two items are not null I want to display true in HTML. I've searched but I can't find an expression or ng directive.

<table class="table table-bordered table-striped">
                <thead>
                    <tr>
                        <th>Account Enabled?</th>
                        <th>Username</th>
                        <th>Date Registered</th>
                        <th>User Displayname</th>
                        <th>Password Reset?</th>
                        <th>Password Valid To</th>
                        <th>Log On Count</th>
                        <th>Last Logged On</th>
                        <th>Is Primary Account?</th>
                        <th></th>
                    </tr>
                </thead>
                <tbody>
                    <tr data-ng-repeat="item in onlineAccounts.CommunicationMethods">
                        <td>
                            {{item.IsEnabled}}
                        </td>
                        <td>
                            {{item.UserName}}
                        </td>
                        <td>
                            {{item.CreatedOn}}
                        </td>
                        <td>
                            {{item.OnlineDisplayName}}
                        </td>
                        <td>
                            {{}}
                        </td>
                        <td>
                            <div ng-if="item.PasswordResetTokenValidTo != null &&  item.PasswordResetTokenValidTo != null">True</div>
                            <div ng-if="item.PasswordResetTokenValidTo == null item.PasswordResetTokenValidTo == null">False</div>
                        </td>
                        <td>
                            {{item.LogOnCount}}
                        </td>
                        <td>
                            {{item.LastLoggedOn}}
                        </td>
                    <td>
                            {{item.IsDefault}}
                    </td>
                </tr>
                </tbody>
            </table>

This is the line I want to change:

  <div ng-if="item.PasswordResetTokenValidTo != null &&  item.PasswordResetTokenValidTo != null">True</div>
                            <div ng-if="item.PasswordResetTokenValidTo == null item.PasswordResetTokenValidTo == null">False</div>

I get the error:

Error: [$parse:syntax] Syntax Error: Token 'item' is an unexpected token at column 40 of the expression [item.PasswordResetTokenValidTo == null item.PasswordResetTokenValidTo == null] starting at [item.PasswordResetTokenValidTo == null].

Is there any angular guru that can help me out?

Share Improve this question asked Mar 25, 2015 at 10:25 nick gowdynick gowdy 6,53127 gold badges95 silver badges158 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

You forgot &&

<div ng-if="item.PasswordResetTokenValidTo == null && item.PasswordResetTokenValidTo == null">False</div>
---------------------------------------------------^^

You forgot &&

<div ng-if="item.PasswordResetTokenValidTo == null && item.PasswordResetTokenValidTo == null">False</div>

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745437211a4627663.html

相关推荐

  • javascript - AngularJS - check for null item in ng-repeat - Stack Overflow

    I am using ng-repeat to display rows in a table and when two items are not null I want to display true

    4小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信