Angular 角度4+;网页包+;UI路由器和lazyloading(无systemjs)
我正在学习ngModules教程() 结合UI路由器()的快速启动示例 我对Angular 4的设置仅限于网页包 我试图在不使用SystemJS的情况下让lazyloading工作。不确定这是否可能 我还使用Pug模板,我导入的模板如下:Angular 角度4+;网页包+;UI路由器和lazyloading(无systemjs),angular,webpack,angular-ui-router,Angular,Webpack,Angular Ui Router,我正在学习ngModules教程() 结合UI路由器()的快速启动示例 我对Angular 4的设置仅限于网页包 我试图在不使用SystemJS的情况下让lazyloading工作。不确定这是否可能 我还使用Pug模板,我导入的模板如下: import template from './contact.component.pug'; @Component( { selector: 'app-contact', template: template(), } ) Mytsconfig.
import template from './contact.component.pug';
@Component( {
selector: 'app-contact',
template: template(),
} )
Mytsconfig.json
:
{
"compilerOptions": {
"target": "es5",
"module": "es2015",
"moduleResolution": "node",
"sourceMap": true,
"removeComments": false,
"typeRoots": [
"node_modules/@types/"
],
"outDir": "./dist/",
"baseUrl": "./src/app/typings",
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"skipLibCheck": true,
"lib": [
"es2015",
"dom"
]
},
"include": [
"src/**/*"
],
"exclude": [
"node_modules",
"**/*.spec.ts"
]}
我尝试使用SystemJS,就像在UI路由器快速启动示例中一样,但这破坏了我的pug模板的加载(导入将不起作用,结果未定义)
看来我处在两个世界之间
我唯一的问题是无法以惰性方式加载crisis.module
export let MAIN_STATES: Ng2StateDeclaration[] = [
// The top-level app state.
// This state fills the root <ui-view></ui-view> (defined in index.html) with the AppComponent
{ name: 'app', component: AppComponent },
{ name: 'app.crisis.**', url: '/crisis', lazyLoad: loadNgModule( 'src/app/common/crisis/crisis.module' ) },
];
export let MAIN_STATES:Ng2StateDeclaration[]=[
//顶级应用程序状态。
//此状态使用AppComponent填充根目录(在index.html中定义)
{name:'app',component:AppComponent},
{name:'app.crisis.*',url:'/crisis',lazyLoad:loadNgModule('src/app/common/crisis/crisis.module'),
];
有人有提示吗?您正在使用webpack吗?有一个Web包示例应用程序在itawesome中具有延迟加载。我去看看。有棱角的CLI使生活更轻松,不是吗