Jump to content

Angular help needed for a scenario


MegaPowerRockstar

Recommended Posts

In html, i have an attribute that i want to be present or deleted based on a flag.

ex:
html tag: <p class="tip" cust-attr="{{vm.propertyValue}}"><span>{{vm.labelText}}</span></p>
flag: vm.display

The above should be transformed to, if:

  1. vm.display === true then <p class="tip" cust-attr="{{vm.propertyValue}}"><span>{{vm.labelText}}</span></p>
  2. vm.display === false then <p class="tip"><span>{{vm.labelText}}</span></p>


I tried below option but did not work, because my attribute has - in between
<h1 ng-attr-contenteditable="{{isTrue || undefined }}">{{content.title}}</h1>

 

I want to do that at html level, not in angular js.

 

what do you think ?

Link to comment
Share on other sites

49 minutes ago, MegaPowerRockstar said:

In html, i have an attribute that i want to be present or deleted based on a flag.

ex:
html tag: <p class="tip" cust-attr="{{vm.propertyValue}}"><span>{{vm.labelText}}</span></p>
flag: vm.display

The above should be transformed to, if:

  1. vm.display === true then <p class="tip" cust-attr="{{vm.propertyValue}}"><span>{{vm.labelText}}</span></p>
  2. vm.display === false then <p class="tip"><span>{{vm.labelText}}</span></p>


I tried below option but did not work, because my attribute has - in between
<h1 ng-attr-contenteditable="{{isTrue || undefined }}">{{content.title}}</h1>

 

I want to do that at html level, not in angular js.

 

what do you think ?

I would use both p tags one with ng-show true and another with no-show false. 

Link to comment
Share on other sites

try ng-if or ng-show or write your own function.

  asalu nuvvu emi cheyyali anukuntnnavo naku ardam kale.  the above should be transformed to ani oka 2 lines of code rasav.  I tried ani cheppi totally different line of code rasav.

Link to comment
Share on other sites

15 minutes ago, pahelwan said:

<h1 ng-attr-contenteditable="{{isTrue || undefined }}">{{content.title}}</h1>

Why can't use something like this?

<h1 contenteditable="{{isTrue ?  value :  undefined}}">{{content.title}}</h1>

or try this

<h1 ng-attr-contenteditable="{{isTrue}}">{{content.title}}</h1>

Edited by Symo
updating answer
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...