I used to do mostly WPF/WinForms development, and we're using mostly Angular at my new company. I'm working on getting my head around the Angular way to do things, and there's one part that I can't seem to find an Angular equivalent or alternative for.
In WPF, I can build a UI component for something that's used in multiple places at multiple levels, and create it in code, passing an object to display to it. In any interface I build that uses this, I can include zero, one, or multiple of these components, and since they get created and passed their data in the code for the parent object, it's clear what data they're displaying and where it's coming from, with the child items having no dependency on the parent item structure. I can't seem to find a clean way to do anything like this in Angular. I can create a child Controller and attach it to a child item inside a parent with the usual ngController directive, and even do several of them per page, but I can't seem to find a good way to pass data to it from the parent. Using ngInit seems to kind of make sense, as I can pass a particular item on the parent $scope to a particular variable on the child scope, but this is apparently not the Angular way, and I'm supposed to be using a Service instead. But since Services are singletons, I don't understand how I can have 0, 1, 2, or 3 child controllers and pass each of them data from a different variable in the parent controller without introducing dependencies on the parent in the child. I could create a service and have the parent item store the data in it, and have the child controller retrieve it, but if I had 3 copies of the same child controller, all displaying data from a different object that the parent has, how would each one know what to get from the service? -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
