Unable build the angular 2 project using ng build

2019-08-04 02:12发布

问题:

I have created a angular 2 project using angular material. I am trying to host my project using firebase deployment process.

My application is successfully running on my server.But when I am trying to build my application its giving me the following error as shown below in the image.


please help me to resolve this

回答1:

Solution: for let- is only support for ng-template error.

You have use let-variablename some where in you html side. The error says you can't use it anywhere instead of ng-template.

Solution 1.

Use ng-template wherever you are using NgForOf

like below this,

if you are using this kind of below code.

 <div ngFor let-variableName [ngForOf]="ListOfData" let-index=index ></div>

Then it should be change it into ng-template

 <ng-template ngFor let-variableName [ngForOf]="ListOfData" let-index=index ></ng-template>

Solution 2

Use this below for loop

*ngFor="let variableName of ListOfData; let index = index"

instead of which is you are using kind

ngFor let-variableName [ngForOf]="ListOfData" let-i=index 

I hope this above both solutions are helps you.

Edit:

Run with this below command instead of yours

 ng build --prod --aot=false --build-optimizer=false


回答2:

Check if you have included angular form in your app module and imported it properly

import { FormsModule } from '@angular/forms';

Again if it doesn't work , then trying removing --aot --prod build . Aot optimizes your build , so probably any of your unused code might be causing build problem