Home Accessing ng-transclude data in directive
Reply: 0

Accessing ng-transclude data in directive

user1028 Published in May 23, 2018, 8:30 pm

I'm still learning AngularJs and I've run into a situation that I can't seem to find any answer for.

I am using ng-transclude inside of a directive as follows:

function highlight(){
   'use strict';

    return {
       restrict: 'E',
       template: highlightReplace,
       transclude: true

    function highlightReplace(scope, element) {
       return "<span class='highlight'><ng-transclude></ng-transclude></span>";

This is all working as expected. What I would like to do at this point is access what the ng-transclude actually is inside of the directive...for instance...if I have the following:

<highlight>Han Solo is dead!</highlight>

I would like to be able to use the text "Han Solo is dead!" inside the directive (this will be used to determine if something should actually be highlighted or not...just an FYI).

Any direction would be appreciated! Thank you!

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.390605 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO