Angular ui-router: ui-views vs directives?

How about if you used Angular UI router’s inline views to point to directives?

Let’s say you have a directive for a table that handles CRUD operations on user accounts. We’ll say the directive is named user-admin. Our routes file would look like:

.state('users', {
  url: "https://stackoverflow.com/users",
  template: "<user-admin>"
});

This would give you many nice things:

  • Allow you to have a url that points straight to a directive
  • Removes the duplication of needing two templates (view template and directive template) when a state is just a directive
  • Allow you to start moving more controller logic into directives in prep for Angular 2.0. See here and here.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)