How to do nested includes in angular work?


Manolovnikola

I can't get nested includes to work.

There are two directives, both of which declare that they will contain their content. When I nest them, there is nothing inside.

Below is this fiddle that demonstrates my problem.

Here is the code:

function Ctrl($scope) {
  $scope.text = 'Neque porro quisquam est qui dolorem ipsum quia dolor...';
}

angular.module('transclude', [])
 .directive('outer', function(){
    return {
      restrict: 'E',
      replace: true,
      transclude: true,
      scope: {},
      template: '<div style="border: 1px solid black;">' +
                '<div>Outer</div>' +
                '<inner ng-transclude></inner>' +
                '</div>'
    };
 }).directive('inner', function(){
     return {
         restrict: 'E',
         transclude: true,
         replace: true,
         template :'<div style="border: 1px solid red;">' +
                   '<div>Inner</div>' +
                   '<div ng-transclude></div>' +
                   '</div>'
     };
 });
Shreyance Jain

You should ng-transculde inside the inner directive as transclude replaces the inner html

angular.module('transclude', []).directive('outer', function(){
    return {
        restrict: 'E',
        replace: true,
        transclude: true,
        template: '<div style="border: 1px solid black;">' +
            '<div>Outer</div>' +
            '<inner><div ng-transclude></div></inner>' +
            '</div>'
        };
});

No need to change internal instructions.

I updated the fiddle here

Related


How to pass includes down through nested directives in Angular?

Jason I'm trying to figure out how to pass a containing object down through nested directives and bind to data in the innermost directive. Think of it as a list-type control, where you bind it to a list of data, and contains is the template you want to use to

How to do nested includes for n+1 in Rails

Ben Morgan Here's what happened: I am in the controller: @products = Spree::Product.all_active and in the model: Spree::Product.class_eval do def self.all_active includes(:master) .where('available_on IS NULL OR available_on < ?', Time.now).where(de

How to do nested includes for n+1 in Rails

Ben Morgan Here's what happened: I am in the controller: @products = Spree::Product.all_active and in the model: Spree::Product.class_eval do def self.all_active includes(:master) .where('available_on IS NULL OR available_on < ?', Time.now).where(de

How to do nested includes for n+1 in Rails

Ben Morgan Here's what happened: I am in the controller: @products = Spree::Product.all_active and in the model: Spree::Product.class_eval do def self.all_active includes(:master) .where('available_on IS NULL OR available_on < ?', Time.now).where(de

Do nested Angular module imports work?

333 Matt Suppose app.module imports AntModule, and AntModule imports BeeModule, and BeeModule exports StingComponent. Will app.module get a reference to the StingComponent or will I need to import the BeeModule directly? Suren Srapyan Do nested Angular module

Do nested Angular module imports work?

333 Matt Suppose app.module imports AntModule, and AntModule imports BeeModule, and BeeModule exports StingComponent. Will app.module get a reference to the StingComponent or will I need to import the BeeModule directly? Suren Srapyan Do nested Angular module

How do I get GTK includes to work with C++?

Gillis I'm trying to start learning to develop GTK+ applications on Ubuntu 17.04 64bit using C++ and the Eclipse CDT IDE, and I'm having trouble trying to include the GTK library. I'm wondering why the include doesn't work. I've installed gtk 2.0 (DEV) and rec

How do I get GTK includes to work with C++?

Gillis I'm trying to start learning to develop GTK+ applications on Ubuntu 17.04 64bit using C++ and the Eclipse CDT IDE, and I'm having trouble trying to include the GTK library. I'm wondering why the include doesn't work. I've installed gtk 2.0 (DEV) and rec

How do I get GTK includes to work with C++?

Gillis I'm trying to start learning to develop GTK+ applications on Ubuntu 17.04 64bit using C++ and the Eclipse CDT IDE, and I'm having trouble trying to include the GTK library. I'm wondering why the include doesn't work. I've installed gtk 2.0 (DEV) and rec

How do I get GTK includes to work with C++?

Gillis I'm trying to start learning to develop GTK+ applications on Ubuntu 17.04 64bit using C++ and the Eclipse CDT IDE, and I'm having trouble trying to include the GTK library. I'm wondering why the include doesn't work. I've installed gtk 2.0 (DEV) and rec

How do I get GTK includes to work with C++?

Gillis I'm trying to start learning to develop GTK+ applications on Ubuntu 17.04 64bit using C++ and the Eclipse CDT IDE, and I'm having trouble trying to include the GTK library. I'm wondering why the include doesn't work. I've installed gtk 2.0 (DEV) and rec

How to do nested subscriptions in Angular?

roof tiles Hello, I have a nested subscription in my Angular, I do it in the following way, I heard it's a bad way. Can anyone let me know the best way? It will really help me learn. Below is my code, please take a look. TIA log-in name login(email: string, p

How to do nested subscriptions in Angular?

roof tiles Hello, I have a nested subscription in my Angular, I do it in the following way, I heard it's a bad way. Can anyone let me know the best way? It will really help me learn. Below is my code, please take a look. TIA log-in name login(email: string, p

How to do nested subscriptions in Angular?

roof tiles Hello, I have a nested subscription in my Angular, I do it in the following way, I heard it's a bad way. Can anyone let me know the best way? It will really help me learn. Below is my code, please take a look. TIA log-in name login(email: string, p

How to do nested subscriptions in Angular?

roof tiles Hello, I have a nested subscription in my Angular, I do it in the following way, I heard it's a bad way. Can anyone let me know the best way? It will really help me learn. Below is my code, please take a look. TIA log-in name login(email: string, p

How to do nested subscriptions in Angular?

roof tiles Hello, I have a nested subscription in my Angular, I do it in the following way, I heard it's a bad way. Can anyone let me know the best way? It will really help me learn. Below is my code, please take a look. TIA log-in name login(email: string, p

How to do nested subscriptions in Angular?

roof tiles Hello, I have a nested subscription in my Angular, I do it in the following way, I heard it's a bad way. Can anyone let me know the best way? It will really help me learn. Below is my code, please take a look. TIA log-in name login(email: string, p

How do nested for loops work when printing?

wild_o: public static void printArrayAsStars(int[] array) { for(int i = 0; i < array.length; i++) { System.out.print("*"); for(int j = 0; j < array[i] - 1; j++){ System.out.print("*" + ""); } System.out.println()

How do I work neatly in nested monads?

wchargin I am writing a translation for a small language. This language supports mutation, so its evaluation tracks Storeall variables (where type Store = Map.Map Address Value, type Address = Intand data Valueare a language-specific ADT). It is also possible

How do nested RxJ retry operators work?

Mo'men El-Zeiny I am using RxJs 5 operable operators in Angular 5. Based on this code sample, how would the retries work? Does the error propagate to the first retry, and if it fails, it propagates to the second? First observe: first() { return Observable.cr

How do nested components work in stencils?

Abishek Gang I found these snippets in Stencil's official documentation. I can't understand how to access my-embedded component in my-parent-component without providing the path to the child component . Can anyone help me understand this concept? Subassembly i

How do nested loops work with jade?

liquid charcoal How do nested loops work in jade? I am trying to generate multiple divs with increasing and decreasing class attribute values. I'm trying the following jade syntax and getting very weird output for 60 divs. Jade code: .row - for (var j = 1; j

How do nested functions work in Python?

eozzy: def maker(n): def action(x): return x ** n return action f = maker(2) print(f) print(f(3)) print(f(4)) g = maker(3) print(g(3)) print(f(3)) # still remembers 2 Why is the first value remembered 2even though the call maker()returns an

How do I work neatly in nested monads?

wchargin I am writing a translation for a small language. This language supports mutation, so its evaluation tracks Storeall variables (where type Store = Map.Map Address Value, type Address = Intand data Valueare a language-specific ADT). It is also possible

How do parameter arguments work with these nested functions?

Chotland I'm trying to improve my understanding of higher order functions and callbacks in the Java language. My code here gives me the desired output, but I'm not sure how it works. My confusion is how the parameters are used in the filterArray for callback ,

How do I work neatly in nested monads?

wchargin I am writing a translation for a small language. This language supports mutation, so its evaluation tracks Storeall variables (where type Store = Map.Map Address Value, type Address = Intand data Valueare a language-specific ADT). It is also possible

How do nested classes with overrides work?

user I would like to know how to explain this mechanism: class Base{ class Other; virtual void test() = 0; }; class Other: Base{ virtual void test() override; }; void Other::test(){ /*do something*/} It seems that I have a base class called Base. It con

How do nested lambdas work in racket?

Guten I know how it lambdaworks, but I get confused when there are a lot of nested lambdas. Can someone explain how nested lambdas work and also how the given code is calculated? ((lambda (x) (x 5)) ((lambda (y) y) (lambda (z) (+ z z)))) Kosa (lambda parameter

How do nested RxJ retry operators work?

Mo'men El-Zeiny I am using RxJs 5 operable operators in Angular 5. Based on this code sample, how would the retries work? Does the error propagate to the first retry, and if it fails, it propagates to the second? First observe: first() { return Observable.cr