0

For example I have 10 template for preview.. see this following example where user comes and enters his/her details and can see live preview.

http://plnkr.co/edit/KNNLPF2Inr3IW2GaRI86?p=preview

// Code goes here
var app = angular.module("myApp", []);

As well as he/she can change template by select template name from available template from select box.

As far I know this can be achieved using angularjs custom directives. But I don't know how to achieve this.

How can be achieved this?

3
  • Please explain the expected behavior better. Commented Jan 31, 2015 at 11:10
  • it's like invitation maker site, where user comes and enter his details then he can able to see his data in live preview with default template. But site has hundred's of template with different design. Now user can able to preview his data with different design by choosing the template from select box... Commented Jan 31, 2015 at 11:26
  • @muni you can use ng-include="template" template name will changed on basis of condition.. Commented Jan 31, 2015 at 11:54

1 Answer 1

3

Here is the solution: Plunker.

  • Using <ng-include src="view"> </ng-include> you can include a template.
  • When the data on the select control is changed, you can change the view variable $scope.view = "x.y.z"; or you can bind the variable of the ng-include with data-ng-model.
Sign up to request clarification or add additional context in comments.

2 Comments

super... I like to know Is this efficient than doing this via custom directive?... Also it will great if you any example this done with the help of custom directive
while there are the angularjs directives for implementing the functionality that you are trying to, imo there is no need to go for custom directives unless you don't trust angularjs as much as your self.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.