title: Angular ui-router: ui-views vs directives?
body: <p>The <a href="https://github.com/angular-ui/ui-router" rel="noreferrer">angular ui-router</a> allows <em>multiple nested views</em>.  The role of these interchangeable views seems to overlap the role of directives.</p>
  
  <p>What are the pros/cons to using (multiple, nested) <strong><code>ui-view</code>s</strong> vs angular's <strong>directives</strong>?</p>
  
  <h3>UPDATE</h3>
  
  <p>States and routing are 2 different functions.  States allow you to swap out partial.html templates and their controllers, and you can <a href="https://stackoverflow.com/questions/22791071/angular-ui-router-can-you-change-state-without-changing-url">(optionally?)</a> specify a corresponding URL/route.</p>
  
  <p>In an email response from Tim Kindberg (a <code>ui-router</code> dev):</p>
  
  <blockquote>
    <p>ui-view is a directive, so if you use it you are using a directive
    that has been worked on particular to work well with the rest of the
    ui-router module. I can't imagine it being easy to roll your own
    directive to replace this functionality.</p>
  </blockquote>
  
  <p>And to this, it seems you could have 2 options:</p>
  
  <p><strong>Normal Directives:</strong></p>
  
  <pre><code>app.directive('myDir1', {/*  controller: ... */})
     .directive('myDir2', {/*  controller: ... */}) 
  </code></pre>
  
  <p>vs <strong>ui-view "Directives"</strong></p>
  
  <pre><code>$stateProvider.state('route1', {
       /*  url: "/route1", // optional?? */
        views: {
          "myDir1": { templateUrl: "myDir1.html" /* , controller: ... */ },
          "myDir2": { templateUrl: "myDir2.html" /* , controller: ... */ }
        }
      })
  </code></pre>
  
  <p>Bonus question:</p>
  
  <p>Are <a href="http://docs.angularjs.org/api/ng/service/$compile" rel="noreferrer">normal angular directive features</a> available to views?  Such as:</p>
  
  <ul>
  <li>Transclude</li>
  <li>Replace</li>
  <li>Isolate scoping</li>
  <li>Compile / linking functions</li>
  </ul>
  
  <p>If ui-views ARE directives, it seems clear their usage is different.  Wouldn't it make sense to harmonize these models?</p>