AngularJS supports append, prepend jQuery functionality. AngularJS append or prepend works exactly like as jQuery.

Steps to append html :

  1. Get angular element of div
  2. Use .append() method to append html to that angular element
var myEl = angular.element( document.querySelector( '#divID' ) );
myEl.append('Hi<br/>');     

Steps to prepend html :

  1. Get angular element of div
  2. Use .prepend() method to prepend html to that angular element
var myEl = angular.element( document.querySelector( '#divID' ) );
myEl.prepend('Hi<br/>');     

Append or Prepend HTML using ng-bind-html

ng-bind-html is for binding HTML to element
<html ng-app="myApp" ng-controller="myCtrl">
......
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular-sanitize.js"></script>
......
<button ng-click="appendText()">append</button>
<button ng-click="prependText()">prepend</button>
......
<div ng-bind-html="divHtmlVar"></div>
......
<script>
var myApp = angular.module('myApp', ['ngSanitize'])
function myCtrl($scope) {
    $scope.divHtmlVar = '<b>main html</b>';
    $scope.appendText = function() {
      $scope.divHtmlVar = $scope.divHtmlVar + '<br/><i>appended text</i>';  
    }
    $scope.prependText = function() {
      $scope.divHtmlVar = '<i>prepended text</i><br/>' + $scope.divHtmlVar;  
    }
}
</script>
Try It Your Self

28 comments:

  1. I am very happy to read this. This blog was really an awesome site which I had never found it anywhere, keep post. front end developers

    ReplyDelete
  2. Big thumbs for making amazing blog. This is the best site. Actually this was an awesome blog post. You have a very inspiring way of exploring and sharing your thoughts. I enjoyed reading your stuff. Thank you !!
    Places for visit in Sedona

    ReplyDelete
  3. I feel it necessary to write a review of this website which I have been a regular visitor of your website for many years. I would gladly recommend this website to someone looking for these kinds of stuff. Thank You!!
    Dental Care in Tijuana Mexico

    ReplyDelete
  4. As a beginner it is a perfect platform your blogs really helps to understand me in a much easier way i regular participate on your website.
    Agency Employment Services

    ReplyDelete
  5. Awesome. I am a beginner and this article helped me to resolve

    the problem .Thank you author and the whole expect team.

    http://www.wikitechy.com/view-article/jQuery-

    bind-onclick-event-to-dynamically-created-elements-part2



    Both are really good,
    Cheers,
    Venkat

    ReplyDelete
  6. It is a fantastic website i usually to come here to enhance the knowledge i spend a great time on your website i appreciate it.
    Casino In UK

    ReplyDelete
  7. I am an experienced web developer in Splendor Design Group and also an intense web reader. Whenever I am getting bored, I would like to reading stuff on web. Thanks for sharing this excellent information and keep posting more.
    splendorgraphics.com/

    ReplyDelete
  8. Awesome work here, I think these stuff is one of the best platforms to get updated with the latest information. I appreciate your effort which you applied on this blog. Thanks & keep writing.
    affordable dentist in Austin TX

    ReplyDelete
  9. This is an extraordinary article it looks so fresh and genuine it does really boost me genius writing i would love to read your new post i am damn sure it would be more interesting.
    1yongevip.ca

    ReplyDelete
  10. Very interesting article, actually i was looking a website like this; It was nice to land on this website post and to see such superb stuff. I have bookmarked it and I will be back for read new blog articles. Thanks for taking the time to share this.
    www.attorneykennugent.com

    ReplyDelete
  11. Excellent blog whenever i feel bored i come here and i get so many new things over your blog thanks for sharing your knowledge able stuff I appreciate your blog. I would love to read more.
    Real Estate Agent In Downsview Park

    ReplyDelete
  12. Well, this is my first visit to your blog! I am very impressed by the way you share awesome and precious content. Thanks for sharing this great blog and keep writing.
    buy salwar suits online

    ReplyDelete
  13. Thumps up for your knowledge able stuff for enhance the knowledge glad to come here this is an amazing to read your blog looking forward.
    Real Estate Agents Ottawa

    ReplyDelete
  14. Individual who made this post, this was an extremely useful for me. Acknowledges for posting this, I saw a unite else alike notify however yours was the prime so deep, always has really good posts and topics please keep it up!
    Wellwisdom.com/ultimate-grass-fed-whey-protein

    ReplyDelete
  15. Well, I observed genius writing skills and i love too read your blog regularly it is very entertaining and acquainting blog appreciate your wisdom.
    Grandviewfamilydentistry

    ReplyDelete
  16. Well, I am so fascinate to come over blog regularly it seems very up-to-date your blog keep me update it is really hard to keep updates own self in this busy life. Your blog is a way who hence and as well as aware me about new things so keep writing cheers.
    mcitycondosvips.ca

    ReplyDelete
  17. You have an actual capacity for composing remarkable Stuff. I think this stuff is one of the best platforms to get updated with the latest information. Thanks & keep writing.
    http://www.virginhairfixx.com

    ReplyDelete
  18. I was searching a site like this, because I found all information here. Your all articles are amazing and i enjoy to read your all blogs and I would really like to read your new articles.
    Luxurious apartment in Panda Condos

    ReplyDelete

  19. When taking a look at the location the initial thing that comes to mind is accessibility as well as benefit. North York condos are located in the North end of Toronto and also are close to lots of highways as well as main artery roadways that give access to other parts of the city. Condos on 1Yonge Street

    ReplyDelete
  20. Thanks for sharing the great informative article with excellent idea I really enjoyed your article Thanks for sharing this and keep writing. designer suits with price



    ReplyDelete
  21. Well this is an great post I really enjoyed it seems like bulk of knowledge you analogize and your writing skill so high for a newbie it is an amazing post so keep writing about new topics.
    Dentist appleton

    ReplyDelete
  22. Well, this is my first visit to your blog! You have a genuine capacity for composing extraordinary Stuff. It is a fantastic blog its really inspiring and full fill with knowledge.keep it up
    digital marketing services in Florida

    ReplyDelete
  23. I am happy to find this post it's Very informative for me. This blog has useful information I must say you have ability to writing unique and informative content. It's a really inspiring blog with full of knowledge.
    natural whey protein

    ReplyDelete
  24. Hey there I feel so fortunate to come over your blog you express it in a very easiest way I am very much active person over your blog pretty good to read your blog its quit interesting to read your blog always because it looks fresh all the time.
    M City Mississauga

    ReplyDelete
  25. Meta Description - In the HTML body this tag appears as meta name. Here the page is defined in brief. In PSD to CSS/HTML this plays a vital role as Meta description often decides the success or failure of your website. It appears in the search engine results as the description just below the page title.
    StartPoint

    ReplyDelete
  26. Big thumbs for making this amazing blog. This is the best site. Actually this is the awesome blog post. You have a very inspiring way of exploring and sharing your thoughts. I enjoyed reading your stuff. thank you very much. keep it up.

    Polycystic Kidney Disease Treatment

    ReplyDelete
  27. I really needed to build a fast remark keeping in mind the end goal to offer thanks to you for these remarkable substance you are putting on your site. You are continually leading a dynamite work. I should state you have composed incredible article. best schools in west delhi

    ReplyDelete

Blogroll

Follow this blog by Email

Popular Posts