AngularJS composite view with the same directive -
i have question, composite view in angularjs, close 1 : angularjs composite components
however, know if possible have directive includes list of same directive, :
<mydirective name="thecontainer"> <mydirective name="a"/> <mydirective name="b"/> <mydirective name="c"/> </mydirective> thanks,
david.
edit
answering blesh, more precise. i'm trying display boxes (a simple square) can have 1 or many boxes, can have many boxes, etc.
here directive
myapp.directive('box', function () { return { restrict:'e', replace:true, templateurl:"partials/box.html", scope: { name : '@' }, link:function (scope, element, attrs, ctrl) { console.log("trying log " + attrs.name); } } }); here template :
<div class="box"> <div class="box-header"> <div>{{ name }}</div> </div> <div class="box-container"> <!-- display other boxes here--> </div> </div> here interesting code in view :
<box name="top" > <box name="sub" > </box> <box name="sub" > </box> </box> obviously missing tell sub-boxes "hey please display in right place parent , please, parent, adapt size number of children have"
david.
the answer simple, without ng-transclude, angular has no way interpret correctly content of innner html tags. correct way correct template adding ng-transclude this:
<div class="box"> <div class="box-header"> <div>{{ name }}</div> </div> <div class="box-container" ng-transclude> <!-- display other boxes here--> </div> </div>
Comments
Post a Comment