Passing a directive to directive via an object in angularjs -


lets there 2 directive components
1) list
2) profile

"list" should accept data in form of object notation passed through controller , display html or directive components in form of list. example

var obj =[
{
component ://profile directive <profile name="shehzad" age=29/>
},
{
component ://news directive like<news content="headlines" />
}
];

and profile directive contains following ui
<div>
<div> name {{name}}</div>
<div> age {{age}}</div>
</div>

similarly news directive contain following ui
<div>
<div>{{content}}</div>
</div>

i want list component read "obj" , render profile , news directive in list view. can plz explain how above thing can achieved in angularjs

here plunker link:
http://plnkr.co/edit/i1kjhycqmksd2qfiuqo8?p=preview

edit: plunker show how add directive dynamically asked http://plnkr.co/edit/u88ipk?p=preview

you want use directive in other directive, add on list directive view that:

<div ng-repeat="profile in profiles" > <profile name="{{profile.name}}" age="{{profile.age}}" ></profile> </div> 

Comments