Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Usage of <code>otherwise</code> might be what are you looking for.</p> <pre><code>angular.module('MyApp', []) .config(function($routeProvider) { $routeProvider. when('/', {templateUrl:'/home.html'}). // add as many as you want here... otherwise({templateUrl:'/404.html'}); // Render 404 view }); </code></pre> <p><strong>Update:</strong> After reading more carefully the OP question (sorry, quite early around here), I <em>think</em> I have an alternate solution (actually two):</p> <p><strong>1) A <code>$scope</code> variable to the main UI of your <code>ng-view</code> that hides the content</strong></p> <p>This requires <code>ng-show</code> in your view and <code>resolve</code> in your params, then do a <code>$emit</code> to the other controllers in order to tell "Hey, this guy hit a 404, don't display your view"</p> <pre><code>$routeProvider.otherwise({ controller: 'masterController', resolve: { 404: function(){ return true; }; }); angular.module('MyApp', []) .controller('masterController', function($scope, 404) { $scope.isOn404 = 404 ... }) // In the view &lt;div ng-controller="masterController"&gt; &lt;div ng-hide="isOn404"&gt; &lt;!-- Actual content --&gt; &lt;/div&gt; &lt;div ng-show="isOn404"&gt; &lt;!-- 404 Page --&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>Now, this requires that you have a master controller that helps you to manage the rest of your UI. Also, you most likely would need to do some coding to handling the rest of the page instead of just using <code>ng-view</code> (e.g. some controllers that show the current header, body, etc).</p> <p><strong>2) A custom routing system</strong></p> <p>I actually have done this for a specific project: you have a service that sets up a "BackURL" and "FordwardURL"; each <code>$onRouteChange</code> you store where do you go and where do you come from; if the user is about to hit a 404, you can still render it through my original example, but when the user hits back, catch that through AngularJS and render the actual "Back" page. In this case I'm using a library that helps me with the routing on mobile devices called <a href="http://lungo.tapquo.com/">Lungo</a> and a library that the company I work for uses, the <a href="https://github.com/centralway/lungo-angular-bridge">L.A.B</a> (Lungo Angular Bridge). </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload