简体   繁体   中英

Angular $routeProvider infinite routes

In my app.ts I have this defined

angular.module('app').config([
    '$routeProvider', 
    function ($routeProvider) {

    $routeProvider
        .when('/Home', {
            templateUrl: '/Home/HomeView'
        })
        .when('/DashboardView/:AppName', {
            templateUrl: '/Home/DashboardView'
        })
        .otherwise({ 
            redirectTo: '/Home' 
        });
}]);

The route works just fine for any AppName that I have defined in my DB. How do I limit the routes to just the AppNames I have defined. Currently it is accepting routes like "/DashboardView/blahblahblah"

Thanks for the help

Your templateUrl should have .html extension

.when('/Home', {
            templateUrl: '/Home/HomeView.html'
        })
        .when('/DashboardView/:AppName', {
            templateUrl: '/Home/DashboardView.html'
        })
        .otherwise({ redirectTo: '/Home' });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM