In link function from directive I use $compile to add new directive 
dinamicly. When append complied template directly to element everything is 
OK, but when I want to append to a child of element nothing happens. 

Below is link function
    post: function (scope, element) {
                      
                        if (scope.question) {
                            if (scope.question.Questions) {
                                var linkFn = 
$compile($templateCache.get('rating/components/nxgrBuildControl/nxgrBuildControl.tpl.html'));
                              
                                scope.question.Questions.forEach(function 
(subQuestion) {
                                    if 
((scope.indexObjectKey.indexOf('driver') > -1 && subQuestion.ModelLevel == 
103) || (scope.indexObjectKey.indexOf('vehicle') > -1 && 
subQuestion.ModelLevel == 103) || subQuestion.ModelLevel != 102 && 
subQuestion.ModelLevel != 103) {
                                        var childScope = scope.$new();
                                        childScope.question = 
angular.copy(subQuestion);
                                        childScope.tag = subQuestion.Tag;

                                        childScope.category = 
scope.category;
                                        childScope.baseModel = 
scope.baseModel;
                                        childScope.uniqueCode = 
scope.uniqueCode;
                                        childScope.vehicleIndex = 
scope.vehicleIndex;
                                        childScope.driverIndex = 
scope.driverIndex;
                                        childScope.incidentIndex = 
scope.incidentIndex;
                                        childScope.indexObjectKey = 
scope.indexObjectKey;
                                        childScope.checkboxLabelPosition = 
scope.checkboxLabelPosition;
                                        childScope.textboxLabelPosition = 
scope.textboxLabelPosition;
                                        childScope.listLabelPosition = 
scope.listLabelPosition;
                                        childScope.showLabel = 
scope.showLabel;
                                        childScope.hideMargin = 
scope.hideMargin;
                                        childScope.collapseLabel = 
scope.collapseLabel;
                                        childScope.labelClass = 
scope.labelClass;
                                        childScope.inputClear = 
scope.inputClear;
                                        childScope.readOnly = 
scope.readOnly;
                                        childScope.questionIndex = 
scope.questionIndex;
                                        childScope.itemGroupClass = 
scope.itemGroupClass;

                                       
                                           THIS CODE WORKS
                                        
//$compile($templateCache.get('rating/components/nxgrBuildControl/nxgrBuildControl.tpl.html'))(childScope,
 
function (cloned, scope) {
                                        //    cloned.css('padding-bottom', 
'5px');
                                        //    cloned.css('padding-left', 
'30px');
                                        //    element.append(cloned);

                                        //}); 
                                        THIS DOESN'T WORK
                                        linkFn(childScope, function 
(clonedElement) {                                        

                                            var headingContainer = 
angular.element("#" + subQuestion.ParentTag + 'Sub');
                                            
clonedElement.css('padding-bottom', '5px');
                                            
clonedElement.css('padding-left', '30px');
                                            
headingContainer.append(clonedElement);
                                        });


                                    }
                                });
                            }
                        }

                    }


-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to