1

Hi,

I am currently looking to implement something like this (AngularJS):

$routeProvider
    .when('/root/:controllerName/blah/:blahId/blah/:blah', {
        templateUrl: '/tmpl/:controllerName/blah/partials/:blah' + '.html',
        controller: ':controllerName' + 'Ctrl'
    })

This is probably overly complicated (with the 'blah, blah, blah') but I wanted to make sure it is clear.

In a nutshell, I'm aiming to accomplish something similar (enough) to how Microsoft MVC employs their routing to controllers -- in other words, very autonomous:

routes.MapRoute(
    "Default",                                              // Route name
    "{controller}/{action}/{id}",                           // URL with parameters
    new { controller = "Home", action = "Index", id = "" }  // Parameter defaults
);

After that, I intend to LazyLoad the controller (which I have already), but this needs to be (hopefully) compatible with LazyLoading.

Has anyone had success with this approach, know of any resources, or have any ideas about how to accomplish this?

--PreThanks

1 Answer 1

1

I do not think you will be able to resolve this using ngRoute but I think ngInclude should be able to help:

Html

<div class="slide-animate-container">
    <div ng-include="template.url"></div>
  </div>

Controller

$scope.template.url = "";//some dynamic rules

Here is a link to angular documentation on this:

https://docs.angularjs.org/api/ngRoute/directive/ngView

Sign up to request clarification or add additional context in comments.

1 Comment

Thx Dalorzo, I've been using when('...', template: '<div ng-include="'/r/o/u/t/e/{{view}}'" ="" ng-controller="MyCtrl"></div>', controller: 'WhateverCtrl', controllerAs: 'MyCtrl'), where a resolver loads the :controller and aliases it under 'MyCtrl' -- but I would like to be able to do an entire 'pre-config' of the .when(...) and have Angular $interpolate the templateUrl and require a controller (and call a delegate to fetch styles conditionally). Thanks for the input, Dalorzo :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.