DOM-IF with two conditions

2,762 views
Skip to first unread message

rof2...@gmail.com

unread,
Sep 2, 2016, 9:01:11 PM9/2/16
to Polymer
Hi all,

I am trying to create a template dom-if with two conditions, but not working, any helps ?

See my code:

<template is="dom-if" if="{{user.isAuthenticated && !user.isAdmin}}">
  <h2>Hello [[prop1]]</h2>
  <form id="formLogout" is="iron-form" action="/security/deauthentication" method="post">
    <paper-button raised on-tap="doLogout">Sair</paper-button>
  </form>
</template>


fja...@gmail.com

unread,
Sep 5, 2016, 5:54:05 AM9/5/16
to Polymer, rof2...@gmail.com
Hi, 

You can't do it in this way, try to do something like that:

<template is="dom-if" if="{{myTestFunction(user.isAuthenticated,user.isAdmin) }}">

 
<h2>Hello [[prop1]]</h2>
 
<form id="formLogout" is="iron-form" action="/security/deauthentication" method="post">
   
<paper-button raised on-tap="doLogout">Sair</paper-button>
 
</form>
</template>
<script>
Polymer({
  is
:"your-component",
  properties
:{
    prop1
:{
       type
:String
   
},
   
...
 
},
 
myTestFunction: function(isAuthenticated,isAdmin){
   
return isAuthenticated && !isAdmin;
 
}

})
</script>



abhi...@quintoapp.com

unread,
Nov 2, 2016, 11:46:31 PM11/2/16
to Polymer, rof2...@gmail.com, fja...@gmail.com
myTestFunction is called only when one argument is passed. On passing two arguments, the function isn't called.
Reply all
Reply to author
Forward
0 new messages