J
J
JIakki2015-02-20 16:14:04
JavaScript
JIakki, 2015-02-20 16:14:04

Is it possible to get all defined directives in the current scope?

Good afternoon.
I've been struggling with the problem for a whole day
Code:

<book>
   <lief ng-repeat='link in [1,2,3,4]>
        <img ng-src='{{link}}.png' >
   </lief>
</book>

app.directive('book', function () {
    return {
      template: 	'<div class="ng-book" ng-transclude>' +				
            '</div>',
      replace: true,
      transclude: true,
      restrict: 'E',
      controller: function ($scope) {
      
      },
      link: function(scope, elem, attr, controller) {
        
      }
    };
  });

  
app.directive('lief', function () {
    return {
      template: '<div class="ng-lief" ng-transclude></div>',
      //templateUrl: 'directive.html',
      replace: true,
      transclude: true,
      restrict: 'E',
      controller: function ($scope) { 
        
      },
      link: function(scope, elem, attr, controller) {
        
      }
    };
  });

How to get all images from under the book directive?
Because , lief is inside the book directive. I don't know how to get an image that has already been displayed using the ngRepeat directive.
I can get it like this:
app.directive('book', function () {
    return {
      template: 	'<div class="ng-book" ng-transclude>' +				
            '</div>',
      replace: true,
      transclude: true,
      restrict: 'E',
      controller: function ($scope) {
      
      },
      link: function(scope, elem, attr, controller) {
        $timeout(function () {
                                         elem.find("img");
                                 }, 1000)
      }
    };
  });

But you never know how long it will take Angular to build a HOUSE

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dmitry Dedukhin, 2015-02-20
@Demetros


I didn't really understand the question, but I think you need to specify in the lief directive: you can call a function from the scope of the book directive by adding another picture to it.

J
JIakki, 2015-02-20
@JIakki

Damn, it's so easy for
anyone who is interested, I just used $document.ready (func)

L
lega, 2015-02-21
@lega

You can put a beacon directive to ngsrc that will send information to the top.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question