angularjs - dynamic directive compile passing the right scope -
i have dynamic directive compiles given directive, problem on compile function need provide right scope it, jus thinking how this?
example of directive below, 'directive' scope input dynamic, example <display-users data="users"/>
user part of controller loads directive.
although below compilation works correctly, since not asscociating compilred code right scope (in above case controller one) not diplay users. please can help?
theapp.directive('customcompile', function ($compile) { var dir = { replace: true, // replace original html ? required restrict = "m" restrict: 'e', //can 1 or more of e / / c / m scope:{ directive:'=' }, controller: function ($scope, $http, $attrs) // controller directive { }, compile: function compile($element, $tattrs, $transclude) { return{ post: function postlink($scope, $ielement, $iattrs){ $ielement.parent().append($compile($scope.directive.directive)($scope)); } } } }; return dir; } );
Comments
Post a Comment