--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/angular?hl=en.
If you are creating a html editor, how would you go about building the model for it?Consider a simplified version of this problem . Lets just take div's.
I need a model to hold the data corresponding to each div. This model will hold all the attributes for that div say. Ofcourse, in a html document you arent restricted to creating 1 div. So you will need to be able to create 'n' models... 1 for each div you want to create.
Since you are building the editor you will need 2 views for each of the html elements.1. Edit view - A view where you can use input elements to fill in values for each of the attributes for a node.2. Preview view - Showing / graphically representing the node itself.
So, given this scenario, I was thinking I would need a way of creating multiple models.
On Thu, May 10, 2012 at 9:20 PM, John Lindquist <johnli...@gmail.com> wrote:
I'm not exactly sure what you're asking... creating models on a service then sharing it across "views" (do you mean injecting into a controller then exposing data to the dom through the scope)?
Have you read the dev guide on services? http://docs.angularjs.org/guide/dev_guide.services.injecting_controllers
On Thu, May 10, 2012 at 2:08 PM, ganaraj p r <gana...@gmail.com> wrote:
I have come to understand that if you want to share the same model with multiple views a good practice would be to create a service and then share that service between the different views.Now since a service is a singleton, how do I go about creating 'n' models? Am I missing something really obvious here?If I want to create 'n' instances of a model and each model needs to be shared between more than 1 view, how do we go about it?--
Regards,
Ganaraj P R
--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/angular?hl=en.
--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/angular?hl=en.
To view this discussion on the web visit https://groups.google.com/d/msg/angular/-/P9letYDjN7sJ.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.
function NodeProvider() {
function Node() {
this.name = "";
this.nodes =[];
this.attributes = [];
this.addAttributes = function(name,value) {
this.attributes.push({nodeName:name,nodeValue:value});
};
this.addNode = function(name) {
this.nodes.push({ name: name, nodes: [], attributes:[] });
};
this.deleteNode = function() {