Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8739885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:02:00+00:00 2026-06-13T11:02:00+00:00

all: Is there a way to dynamically add a tag (especially a custom tag)

  • 0

all:

Is there a way to dynamically add a tag (especially a custom tag) in AngularJS?

I have a custom tag recently created of the type:

<mytag type="small" />

which I am attempting to manage in a larger <div> element. What I would like to do is place, within the div element, a button that, when pressed, causes the creation of a new mytag element within the div.

In other words, given an initial page composition:

<div ng-controller="tagControl">
   <div id="tagdiv">
      <mytag type="small" />
   </div>
   <div id="Controls">
      <button ng-click="addTag()">Add New Tag</button>
      <button ng-click="clearTags()">Clear All Tags</button>
   </div>
</div>

I would like to put something in the tagControl’s addTag() function that adds a new mytag tag whenever the “Add New Tag” button is pressed, and I’d like to put something in the clearTags() function that removes all added tags when the “Clear All Tags” button is pressed.

Is this possible using AngularJS? If not, can it be accomplished using a third- party library? In either event, how can this be done?

Thanks in advance for any insights…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T11:02:01+00:00Added an answer on June 13, 2026 at 11:02 am

    You need to think in terms of MVC and not DOM manipulation. How many of your <mytag>s you want to show up should be driven by something in your model. And then your HTML would look like this:

    <div ng-controller="tagControl">
      <div id="tagdiv">
         <mytag type="small" ng-repeat="foo in items" />
      </div>
      <div id="Controls">
         <button ng-click="addTag()">Add New Tag</button>
         <button ng-click="clearTags()">Clear All Tags</button>
      </div>
    </div>
    

    Then your addTag() method would just add to the items model and the clearTags() would clear the list. Angular will add the tags for you as you update the model

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to automatically/dynamically set all the attributes for a datamapper object
Hi All is there any way to locally define a variable in a function
Is there a way to return all the columns in a MySQL table in
Is there a way to download all the Emacs packages from a repository like
Is there a way to select all id's with jQuery with a prefix my
Is there a way to delete all the entries of a dictionary without deleting
Is there a way to get all versions of list item(s) using a CAML
Is there any way to remove all forgeinKey and primary key contriants from Database
is there a way to find all script files added to a page in
Is there any way to reliably capture all changes made to the win32 console

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.