【问题标题】:Need a folder to be routed making all the contains inside that folder available需要路由一个文件夹,使该文件夹内的所有包含都可用
【发布时间】:2017-09-29 05:43:51
【问题描述】:

大家好,我需要实际路由一个文件夹,其中将包含多个文件和文件夹。

For example 
My folder name is Contains -- with inner folder  sample1 sample2.
sample1 folder contains --  app.js index.js Index.html 
sample2 folder contains --  app.js index.js Index.html

so I want routes for like every file in each folder's 
example --  localhost:3030/Contains/sample1/Index.html
localhost:3030/Contains/sample2/Index.html
localhost:3030/Contains/sample1/index.js
localhost:3030/Contains/sample1/app.js
... etc 

如何使用 stateProvider 实现这一点?

提前致谢

【问题讨论】:

  • 为什么你想要 js 文件的路由?对于 HTML,您可以直接在 templateURL 中提供路径
  • 我实际上有一个 Scorm 课程文件夹,我希望加载与该原因相关的所有内容。所以需要路由该文件夹中的每个文件。

标签: angularjs routes


【解决方案1】:

据我了解您的问题,我使用的是三层嵌套

var app = angular.module("Appp", ['ui.router']);
    app.config(function($stateProvider, $urlRouterProvider) {
        $stateProvider
            .state('userSetting', {
                url: '/userSetting',
                templateUrl: 'templates/userSetting.html'
            })
            .state('settings.profile.user', {
                url: '/profile',
                templateUrl: 'templates/profile.html',
                controller: 'ProController'
            })
            .state('settings.account.user', {
                url: '/account',
                templateUrl: 'templates/account.html',
                controller: 'AccController'
            });
        $urlRouterProvider.otherwise('/userSetting/profile');
    });

【讨论】:

  • 三层嵌套很好,但在这种情况下,我将不得不声明多条路线。并且原因文件夹实际上将包含超过 40 个文件
猜你喜欢
  • 1970-01-01
  • 2016-02-26
  • 2011-07-18
  • 1970-01-01
  • 2013-10-10
  • 2014-01-14
  • 1970-01-01
  • 2013-11-22
相关资源
最近更新 更多