Is it possible to have multiple states on the page at once or change the state of a named view?

I am developing a page that has a news feed; when I think about it logically, this feed has multiple states (news, settings, favorites, etc.).

The feed needs to be accessible on many types of pages, for example, for a product or person or whatever, so I understand that the feed itself must have states because their parent page can have all sorts of others claiming food doesn't care, and vice versa.

I can't figure out how to do this - at first I thought I could accomplish this using a named view on the parent page, but I can't figure out if the view can have state, or how I would code it.

How should I implement this structure?

+3


source to share


1 answer


What you are looking for looks like a directive:

  • A directive usually has an HTML template associated with it
  • The directive maintains this HTML template with a scope that can (and usually should) be page-scope independent, but only a few explicitly defined parameters (values ​​and / or functions) passed to it
  • A directive can define specific behaviors and functions, just like a normal page would through its controller
  • A directive can nevertheless link to its parent page because it shares its scope (usually a bad idea) or because there is a two-way binding of select boxes
  • If desired, the directive can bind to other directives (in your application this can be useful if you, for example, define the directive "rss-feed" and "rss-news item")

The states will be variables, some of which you get to your directive from your page, some of which you compute inside the directive. These, in turn, will parameterize the HTML schema template with the normal angular behaviors (e.g. ng-hide / show some subcomponents).



Angular directive doc: https://docs.angularjs.org/guide/directive Good tutorial: http://www.sitepoint.com/practical-guide-angularjs-directives/

Does this answer your question?

0


source







All Articles