I am looking to make a reusable controller and push the data I want to use as the model. Let me explain this using stack overflow as a model. I would implement an analytics dashboard for tags.
It would have an outer controller that would have a list of the most common tags <div ng-controller="TagsAnalyticsController as tags"> Then I want two inner controllers, one would have a graph and a line for each tag with the number of comments over time. Another would provide the most recent questions for a given tag <div ng-controller="GraphController as graph" ng-init="graph.init(tags.names)"> <div ng-repeat="name in tags.names> <div ng-controller="CommentsController as comments" ng-init="comments.init(name)"> You can imagine links in the outer view would navigate the user to another page with more information for that tag, including the graph and comments controllers reused. <div ng-controller="TagController as tag"> <div ng-controller="GraphController as graph" ng-init="graph.init([tag.name])"> <div ng-controller="CommentsController as comments" ng-init="comments.init(tag.name)"> But in this case I have used ng-init which is bad for at least two reasons 1. Documentation says that ng-init is not recommended 2. If tags.names change the html won't be updated with the new names. So what is the best way to do this, without coupling the controllers together? -- 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 https://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
