"Cant bind to" 错误只出现在生产中

"Cant bind to" error only shows up in production

为什么我在使用 Angular 4 + webpack 的生产中得到 "can't bind to... since it isn't a known property of ... error"?

Angular版本为4.1.3,webpack版本为2.6.1。在我本地是没有问题的。一切正常。在生产中,我将所需文件从 "npm run build" 上传到 weblogic。然后我面临这样的错误:

Unhandled Promise rejection: Template parse errors: Can't bind to 'ngclass' since it isn't a known property of 'div'.

Can't bind to 'ngif' since it isn't a known property of 'div'. ("i [blocked]=notifier.blocked [target]=pnl> ] ngif="session && session.activeUser">

我的依赖项: My dependencies

Webpack 版本:Webpack versions

我试过这个: 并添加了浏览器模块,但仍然无法在产品中工作。

打字没有问题:

<div class="ui-grid" *ngIf="session && session.activeUser">
<model-dialog-component #modelDialog [contentFactory]='modelDialogContentFactory'></model-dialog-component>
<div class="ui-grid-row">
    <div class="ui-grid-col-12">
        <div class='headers'>
            <div class='header'>
                <div id='logo'>
                    <span routerLink='home'><img [src]='logoPath' /></span>
                    <div class='mobile-nav' [ngClass]="acln ? 'op':'hd'" (click)='mnav($event)'>
                        <i class='icon-menu'></i>
                    </div>

我通过在 webpack.prod.js 中设置 minimize=false 解决了问题。像这样:

new webpack.LoaderOptionsPlugin({
        options: {
            htmlLoader: {
                minimize: false
            }
        }
    }),