简体   繁体   中英

How to put multiple condition inside one ng-if statement using Angular.js

I need one help. I need to put multiple condition inside one ng-if directive using Angular.js but getting the below error.

Error: [$parse:syntax] Syntax Error: Token '<' not a primary expression at column 87 of the expression [$parent.$parent.$index != 1 && $parent.$index != 0 && $index !=1>
                    <div class=] starting at [<div class=].
http://errors.angularjs.org/1.4.7/$parse/syntax?p0=%3C&p1=not%20a%20primary%20expression&p2=87&p3=%24parent.%24parent.NaNndex%20!%3D%201%20%26%26%20%24parent.%index%20!%3D%200%20%26%26%20%24index%20!%3D1%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3Cdiv%class%3D&p4=%3Cdiv%class%3D
    at http://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.js:68:12
    at AST.throwError (http://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.js:13057:11)
    at AST.primary (http://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.js:12960:12)
    at AST.unary (http://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.js:12940:19)
    at AST.multiplicative (http://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.js:12927:21)
    at AST.additive (http://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.js:12918:21)
    at AST.relational (http://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.js:12912:90)
    at AST.equality (http://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.js:12903:90)
    at AST.logicalAND (http://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.js:12894:85)
    at AST.logicalOR (http://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.js:12884:21)

I am explaining my code below.

 <div ng-if="$parent.$parent.$index != 1 && $parent.$index != 0 && $index !=1>
                        <div class="panel-group accordion-content-div accordioninner accordioninner-inner">
                          <div class="panel panel-default" style="border:1px solid #66afe9;">
                            <div class="panel-heading">
                              <a class="panel-title sky-blue-light auditformpopup" role="button" ng-click="getAllNextPreviousIds(cd.sub_sub_id,$index,$parent.$index,$parent.$parent.$index)">
                              {{cd.des}}

</a>
     </div>

  </div>
</div>

Here I have to use the AND operator and here This div has two parent index. I need to compare all those. Please help me to resolve this error.

据我所知,您只是忘记了&& $index !=1>之后的双引号(“) && $index !=1>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM