Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Executing a route without a template #3138

Closed

Description

@logicbomb

This has been opened and closed a few times

I may have found a use case where it's a valid to execute a route that doesn't have an associated template. Imagine a page that launches various modal windows with the requirement to be able to deep-link directly to the page with a dialog open.

The only difference between the modals are the title & text, so the $rootScope is responsible for setting up and launching a modal, and the controller simply provides route specific content.

A workaround is to set { controller: 'fooCtl', template: ' ' }, but it'd be nice to leave the template property out altogether.

Here's a fiddle that shows the problem and workaround: http://jsfiddle.net/EGfAX/5/

Activity

  1. added this to the milestone on Feb 21, 2014
  2. joseluisq commented on May 8, 2015

    @joseluisq

    For example when templateUrl is false:

    var app = angular.module('myApp.foo', ['ngRoute']);
    
    app.config(['$routeProvider', function($routeProvider) {
      $routeProvider.when('/foo', {
        templateUrl: false,
        controller: 'fooCtrl'
      });
    }]);

    Angular loads all controllers again and then the console throws this:

    image

    Finally the browser tab is frozen.

  3. caitp commented on May 8, 2015

    @caitp
    Contributor

    well that's messed up and worth investigating, but setting templateUrl to false doesn't accomplish what you want, so why are you doing that? It doesn't mean anything as far as angular is concerned

  4. joseluisq commented on May 8, 2015

    @joseluisq

    Maybe, but sometimes I need angular route doesn't load by default an template. Because I can load manually my custom template and compile it on the fly.

  5. caitp commented on May 8, 2015

    @caitp
    Contributor

    Right, but you could just use template: "" to achieve that.

  6. caitp commented on May 8, 2015

    @caitp
    Contributor

    in particular, setting templateUrl to false will try to resolve the string "false" as a URL, which should be resolved relative to the current location of the frame (which is almost certainly not what you want)

  7. joseluisq commented on May 8, 2015

    @joseluisq

    In general I think it should exist a validation for templateUrl.
    Thanks, I will try this

  8. Narretz commented on Nov 3, 2016

    @Narretz
    Contributor

    The problem with having an empty or false templateUrl is tracked here: #12176
    Since you can do template: '', it's very easy to have a route "without" a template

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions