Clone a template with dynamic scope in directive

43 views
Skip to first unread message

Suresh K. V.

unread,
Oct 31, 2015, 6:17:16 AM10/31/15
to AngularJS
Hi,

I want different id's for the layouts created in directive. I have created a plunker with detailed code.


Please help me.

Jason Steele

unread,
Nov 1, 2015, 6:24:49 AM11/1/15
to AngularJS

Suresh K. V.

unread,
Nov 3, 2015, 2:40:07 AM11/3/15
to AngularJS
@Jason Steele, thanks for the reply, but it is not working.

Sander Elias

unread,
Nov 3, 2015, 3:28:23 AM11/3/15
to AngularJS
Hi Suresh,

I don't think this is a venue you should follow. This will lead you into a road full of unexpected surprises. I would prefer not to maintain a project that holds stuff like this.
However, what you ask is possible, and I will show you how. Consider this as an academic exercise, not as something you should do in production!
If you need something like this, every 'template' should receive it's own private an new Scope. 

Does this explain it a bit to you?

Regards
Sander

Suresh K. V.

unread,
Nov 4, 2015, 6:04:22 AM11/4/15
to AngularJS
Hi Sander,

Thank you very much for your post. It helped me a lot. Could you please let me know what would be the best solution to do it in the production.

Thanks,
Suresh

Sander Elias

unread,
Nov 4, 2015, 9:55:28 AM11/4/15
to AngularJS
Hi Suresh,

Tell me what it is you need to get done. What is the use in your app of this?

Regards
Sander

Suresh K. V.

unread,
Nov 5, 2015, 9:16:36 AM11/5/15
to AngularJS
Hi Sander,

In our app we need to generate multiple layouts, where user can search the products in our application. Each layout will represent a separate search.

Thanks,
Suresh

Sander Elias

unread,
Nov 5, 2015, 11:00:15 AM11/5/15
to AngularJS
In that case, cant you repeat over an array, and then ng-include the template you need?

Regards
Sander

Suresh K. V.

unread,
Nov 11, 2015, 4:04:54 AM11/11/15
to AngularJS
Hi Sander,

Sorry for late reply. can you please provide a code sample.

Regards,
Suresh

Sander Elias

unread,
Nov 11, 2015, 8:11:07 AM11/11/15
to AngularJS
Hi Suresh,

something like:

<div ng-repeat='template in templates' ng-include='template'></div>

Templates is an array holding the relative url's of your templates.

regards
Sander
Reply all
Reply to author
Forward
0 new messages