javascript - Dynamically add and remove attributes in angular directive template -
Hi I have a tutorial that creates a div tag used to embed the live preview of information about my webpage. In my instructions I have a template that creates this division tag.
However, I only want the required properties that are selected on my webpage so that they are included in the div tag.
In my instructions I have:
var temp = "& lt; div data-feed class = 'feed-element' data-number-activities = {{anta Data-activity-source = '{{mySourceSelections [0]. Source ID}' data-activity-actions data-activity-action-social = {{social media embed selection}}} data-content-range = {{Content limited}} data-action-action-event data-no-activity-message = {{noActivitySelection}} id = 'feedEmbed'> "; Return {Limited: 'E', Scope: false, template: temporary};
Right now, when this div is rendered on my webpage, the specific attributes are different ng-models (such as number of activities, content limits, etc.). However, I want to add / remove those specific characteristics, depending on whether the user has chosen to include that choice in all. For example, data-activity-action-event must not be in the deviant tag, if not selected. How do I do this?
I was thinking of using SPAN and NG-show and NG-hide functions, but I'm not sure when I need to add / remove attributes, this will work.