Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs$routeProvider配置_Angularjs - Fatal编程技术网

Angularjs$routeProvider配置

Angularjs$routeProvider配置,angularjs,Angularjs,我有一个简单的angularjs应用程序,名为testAPP。在它里面我有一个名为URL的常量,我也可以在这个应用程序的其他服务中使用它。现在我需要使用$routeProvider的内部模板URL中的URL.DASHBOARD\u URL。可能吗?如果没有,那么最简单的方法是什么 (function () { angular.module('testAPP', []) .constant("URLS", { "DASHBOARD_URL": '/modu

我有一个简单的angularjs应用程序,名为testAPP。在它里面我有一个名为URL常量,我也可以在这个应用程序的其他服务中使用它。现在我需要使用$routeProvider的内部模板URL中的URL.DASHBOARD\u URL。可能吗?如果没有,那么最简单的方法是什么

    (function () {
    angular.module('testAPP', [])

    .constant("URLS", {
        "DASHBOARD_URL": '/modules/dashboard/dashboardUI.html' 
    })

    .config(['$routeProvider', function ($routeProvider) {

     $routeProvider
                    .when('/', {
                        title: 'website',
                        templateUrl: URLS.DASHBOARD_URL, //Here i need to use
                        controller: '',
                    })

}]);

})();

您可以
常量注入
配置
并使用它,如下所示:

(function () {
   angular.module('testAPP', [])

   .constant("URLS", {
        "WEBSITE": '/modules/dashboard/dashboardUI.html'
    })

    .config(['$routeProvider','URLS', function ($routeProvider,URLS) {

     $routeProvider
       .when('/', {
           title: 'website',
           templateUrl: URLS.WEBSITE,
           controller: '',
        })

  }]);
 })();

您可以
常量注入
配置
并使用它,如下所示:

(function () {
   angular.module('testAPP', [])

   .constant("URLS", {
        "WEBSITE": '/modules/dashboard/dashboardUI.html'
    })

    .config(['$routeProvider','URLS', function ($routeProvider,URLS) {

     $routeProvider
       .when('/', {
           title: 'website',
           templateUrl: URLS.WEBSITE,
           controller: '',
        })

  }]);
 })();