为不以“addin”开头的路由延迟加载某些文件
Lazy-load certain files for routes that don't begin with `addin`
我有一个由 AngularJS
和 angular-ui-router
建立的网站。在 index.html
中,我加载了很多 .js
和 .css
文件。
现在,我意识到 .js
和 .css
文件中的一部分对于像 https://localhost:3000/addin/...
这样的路由来说并不是必需的。所以我只想通过 ocLazyLoad
为 https://localhost:3000/xxxxx/...
这样的路线加载它们,其中 xxxxx
不是 addin
.
有人知道如何在代码中实现吗?
尝试
.state('xxxxx', {
url: '/xxxxx',
templateUrl: 'xxxxx.html',
controller: function($ocLazyLoad) {
$ocLazyLoad.load('xxxxx.module.js');
}
更新
根据您在评论中提出的问题,您不能为 states
点赞 not
。您需要明确映射 states
。
我能想到的创建 not
/addin
状态的一种方法是首先将它们显式映射到 $stateProvider
,然后通过某些 redirect
状态重定向然后加载您想要 延迟加载 的模块。
通过
重定向 addin
以外的状态
我有一个由 AngularJS
和 angular-ui-router
建立的网站。在 index.html
中,我加载了很多 .js
和 .css
文件。
现在,我意识到 .js
和 .css
文件中的一部分对于像 https://localhost:3000/addin/...
这样的路由来说并不是必需的。所以我只想通过 ocLazyLoad
为 https://localhost:3000/xxxxx/...
这样的路线加载它们,其中 xxxxx
不是 addin
.
有人知道如何在代码中实现吗?
尝试
.state('xxxxx', {
url: '/xxxxx',
templateUrl: 'xxxxx.html',
controller: function($ocLazyLoad) {
$ocLazyLoad.load('xxxxx.module.js');
}
更新
根据您在评论中提出的问题,您不能为 states
点赞 not
。您需要明确映射 states
。
我能想到的创建 not
/addin
状态的一种方法是首先将它们显式映射到 $stateProvider
,然后通过某些 redirect
状态重定向然后加载您想要 延迟加载 的模块。
通过
addin
以外的状态