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.

Building Template Url Dynamically #2295

Closed
@iliassays

Description

@iliassays

Hi

See the $routeProvider config.
.when('/Feedback/Details/:id', { templateUrl: '/Feedback/Details/:id', controller: "TestRoute" })

I need to set id with template url dynamically. Is there any option? I do not want to do any Hack like creating a controller and set routeProvider or using ng-include.

Bellow is a option what we can think for parseRoute method. But i do not want to touch the library code.

function parseRoute() {
// Match a route
var params, match;
forEach(routes, function (route, path) {
if (!match && (params = switchRouteMatcher($location.path(), path))) {
match = inherit(route, {
params: extend({}, $location.search(), params),
pathParams: params
});

                        if ((route.templateUrl) && (/:/.test(route.templateUrl))) {
                            match.templateUrl = interpolate(route.templateUrl, params);
                        }
                        //remove cached template if params were substituted (rely on browser cache)
                        if (match.templateUrl != route.templateUrl) {
                            match.template = undefined;
                        }

                        match.$route = route;
                    }
                });
                // No route matched; fallback to "otherwise" route
                return match || routes[null] && inherit(routes[null], { params: {}, pathParams: {} });
            }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions