Encountering a Template Parse Error after running the ng build --prod command

As a newcomer to Angular, I have successfully created a small application that requires a sortable table. Everything works well in Angular-cli development server during development mode (using ng serve).

I've experimented with implementing the table using both ng2-table and angular-table libraries, so I don't think the issue lies with either of these libraries.

However, when I compile the application using ng build --prod for deployment on my staging server, I encounter the following error in the browser console when trying to access the application:

zone.js:461 Unhandled Promise rejection: Template parse errors:
Can't bind to 'rowsOnPageSet' since it isn't a known property of 'mfBootstrapPaginator'. ("                     <td colspan="3">
                                        <mfBootstrapPaginator [ERROR ->][rowsOnPageSet]="[10,25,100]"></mfBootstrapPaginator>
                                    </td>
     "): a@42:62 ; Zone: <root> ; Task: Promise.then ; Value:

Template parse errors:↵Can't bind to 'rowsOnPageSet' since it isn't a known property of 'mfBootstrapPaginator'. ("                     <td colspan="3">↵                                        <mfBootstrapPaginator [ERROR ->][rowsOnPageSet]="[10,25,100]"></mfBootstrapPaginator>↵                                    </td>↵     "): a@42:62"

I have refactored my code to align with Angular 2.0.0RC5, utilizing the new @NgModule decorator.

Any assistance or guidance you can provide would be greatly appreciated, as I am currently stuck.

Thank you

JT

Note: I attempted to temporarily specify the DataTableDirectives as a directive under the component's @Component decorator, but this did not resolve the issue.

app.module.ts

import {NgModule} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {HttpModule} from '@angular/http';
import {DataTableDirectives} from 'angular2-datatable/datatable';
import {AppComponent, APP_ROUTER_PROVIDERS, APP_ROUTES} from './';
import {MapToIterable} from './utils';
import {ServerDataService} from './services';
import {HomeComponent, DecoderStatusComponent, ActivityListComponent, PassingsComponent} from './components';


@NgModule({
    imports: [
        APP_ROUTES,
        BrowserModule,
        HttpModule
    ],
    declarations: [
        AppComponent,
        DecoderStatusComponent,
        ActivityListComponent,
        PassingsComponent,
        HomeComponent,
        MapToIterable,
        DataTableDirectives
    ],
    providers: [
        APP_ROUTER_PROVIDERS,
        ServerDataService
    ],
    bootstrap: [AppComponent]
})
export class AppModule {
}

system-config.ts

/*******************************
 * User Configuration.
 *******************************/

/** Map relative paths to URLs. */
const map: any = {
    'lodash':               'vendor/lodash',
    'rxjs':                 'vendor/rxjs',
    'angular2-datatable':   'vendor/angular2-datatable',
    'ng2-bootstrap':        'vendor/ng2-bootstrap',
    'moment':               'vendor/moment'
};

/** User packages configuration. */
const packages: any = {
    'lodash':               { defaultExtension: 'js', main: 'lodash.js' },
    'rxjs':                 { defaultExtension: 'js' },
    'angular2-datatable':   { defaultExtension: 'js' },
    'moment':               { format: 'cjs', defaultExtension: 'js' },
    'ng2-bootstrap':        { format: 'cjs', defaultExtension: 'js' }
};



/*******************************
 * Everything underneath this line is managed by the CLI.
 *******************************/
const barrels: string[] = [
    // Angular specific barrels.
    '@angular/core',
    '@angular/common',
    '@angular/compiler',
    '@angular/forms',
    '@angular/http',
    '@angular/router',
    '@angular/platform-browser',
    '@angular/platform-browser-dynamic',

    // Thirdparty barrels.


    // App specific barrels.
    'app',
    'app/shared',
    'app/components',
    'app/model',
    'app/services',
    'app/utils'
  /** @cli-barrel */
];

const cliSystemConfigPackages: any = {};
barrels.forEach((barrelName: string) => {
    cliSystemConfigPackages[barrelName] = { main: 'index' };
});

/** Type declaration for ambient System. */
declare var System: any;

// Apply the CLI SystemJS configuration.
System.config({
    map: {
        '@angular': 'vendor/@angular',
        'rxjs': 'vendor/rxjs',
        'main': 'main.js'
    },
    packages: cliSystemConfigPackages
});

// Apply the user's configuration.
System.config({ map, packages });

Passings.html

<div class="panel-body">
                    <div class="row">
                        <div class="col-xs-12 col-md-12">
                            <table class="table table-striped" [mfData]="data" #mf="mfDataTable" [mfRowsOnPage]="10">
                                <thead>
                                <tr>
                                    <th>Passing</th>
                                    <th>Date</th>
                                    <th>Time</th>
                                </tr>
                                </thead>
                                <tbody>
                                <tr *ngFor="let item of mf.data">
                                    <td>{{item[0]}}</td>
                                    <td>{{item[1]}}</td>
                                    <td>{{item[2]}}</td>
                                </tr>
                                </tbody>
                                <tfoot>
                                <tr>
                                    <td colspan="3">
                                        <mfBootstrapPaginator [rowsOnPageSet]="[10,25,100]"></mfBootstrapPaginator>
                                    </td>
                                </tr>
                                </tfoot>
                            </table>
                        </div>
                    </div>
                </div>

Answer №1

Oh, this appears to be a well-known issue that has been documented. Feel free to check it out here:

https://github.com/angular/angular/issues/10618

I highly recommend going through this discussion as it sheds light on most of the problem at hand.

For the time being, avoid minifying your code. If you're utilizing angular-cli, you might have to stick with a development build until the next update is released.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Working with JSON data in Typescript without specified keys

My goal is to extract the IssueId from the JSON data provided below: [ { "-MERcLq7nCj5c5gwpYih": {"CreateDate":"2020-08-11T08:27:13.300Z","Id":"-MERcLq7nCj5c5gwpYih","IssueId":"-ME3-t ...

When using Angular 4 CanActivate guard in conjunction with a service, the component may not load properly. However, by simply using Observable

When attempting to implement the CanActivate guard in Angular, I encountered an issue where it didn't work when calling a service and using return true, or even return Observable.of(true);. However, the guard did work and the component loaded success ...

Array of colors for Wordcloud in Angular Highcharts

I am currently utilizing Angular Highcharts 9.1.0 and facing an issue with generating a word cloud that incorporates specific colors. Despite including color values in the array, they do not seem to be applied as intended. Take a look at the code snippet b ...

Guide on utilizing mongoose's native promise (mpromise) for deleting one document and subsequently updating another document

I am currently exploring the use of promises as a way to avoid deeply nested callbacks in my code. The snippet below showcases what I have implemented: exports.destroy = function(req, res) { var actionID = req.body.id; var promise = Action.findById(a ...

Unable to locate the controller in AngularJS

I am facing an issue with my AngularJS application where I have 2 separate JS files for different modules in different directories. When I try to start my app, I receive an error message stating that the controller SubAppCtrl cannot be found. Can someone p ...

Leveraging FormControlName in Typescript to Interact with HTML Components in Angular 4

How can I use FormControlName to access HTML elements in typescript? Typically, I am able to access HTML elements using their ID. For example: var element = document.getElementById("txtID") But is it possible to access the element without using its ID a ...

Ensuring Map Safety in Typescript

Imagine having a Map structure like the one found in file CategoryMap.ts export default new Map<number, SubCategory[]>([ [11, [100, 101]], [12, [102, 103]], ... ]) Is there a way to create a type guard for this Map? import categoryMap fro ...

To activate a function, simply click anywhere on the body: instruction

One of my latest projects involved creating a directive that allows users to click on a word and edit it in a text box. Once edited, clicking anywhere on the body should return the word back to its updated form. html <div markdown>bineesh</div& ...

The MaxDuration feature for a 5-minute time limit is malfunctioning on the Serverless Pro Plan, resulting in a 504 ERROR on

I am currently using Next.js@latest with App Directory My application is hosted on Vercel I'm experiencing a 504 error from Vercel and I'm on the pro plan. My serverless functions are set to run for up to 5 minutes, but usually, they only take ...

Restricting or postponing HTTP requests in an AngularJS service

I recently developed a service for my AngularJS app that retrieves data by making $http calls through various methods. However, I encountered an issue where these requests were being triggered every time an HTML element in the view (a product details div) ...

Is there a way to cease monitoring a value in AngularJS?

I'm currently working with the following code snippet: $scope.$watch('city', function (newValue, oldValue) { However, I need to find a way to stop the watch when I update the city list. Is there a method to remove the watch? ...

unable to retrieve / interpret data from herdsmen using fetch

When sending a request to a node server, the server responds with headers and a blank body. Despite being able to view the headers in the network activity panel within dev-tools, I faced difficulties reading them using the following code: let uploaded ...

Error encountered in Snap SVG combined with Typescript and Webpack: "Encountered the error 'Cannot read property 'on' of undefined'"

I am currently working on an Angular 4 app that utilizes Snap SVG, but I keep encountering the frustrating webpack issue "Cannot read property 'on' of undefined". One solution I found is to use snapsvg-cjs, however, this means losing out on the ...

Obtaining attribute data value upon selection change in Angular 4

Having trouble retrieving the value from data-somedata in my code... <select class="form-control input-sm" [(ngModel)]="o.id" formControlName="optionals" (change)="menuChange($event)"> <option *ngFor="let menu_optional of menu_optionals" value= ...

What is the best way to extract ABC 12005 from strings like ABC000012005 and ABC0000012005?

My task involves parsing a string with values like ABC000012005,ABC0000012005. The desired output is to extract the prefix and numbers without leading zeros, formatted as ABC 12005, ABC 12005 ...

Issue with Angular app occurring on one device, functioning properly on others - Error: $injector:unpr Unknown Provider

Whenever I try to run my application on my usual Windows machine, I keep encountering the following error: Error: $injector:unpr Unknown Provider Interestingly, the app works perfectly fine on other machines running Windows, MAC, and Linux. Since the we ...

Utilizing a setup module for configuration purposes

In the process of developing my angular application, I have integrated several external modules to enhance its functionality. One crucial aspect of my final application is the configuration classes that store important values like URLs and message keys us ...

At first, the Angular disabled property does not seem to be functioning as

Trying to toggle a button's disabled state based on whether an array is empty or not in an Angular application. The button implementation looks like this: <button (click)="doStuff()" [disabled]="myObject.myArray.length === 0"> ...

Creating HTML elements dynamically with attributes based on the `as` prop in React using TypeScript

Is there a way to dynamically create HTML elements such as b, a, h4, h3, or any element based on the as={""} prop in my function without using if guards? I have seen a similar question that involves styled components, but I am wondering if it can be done ...

Steps to dynamically include a marker on a Google Maps component using HTTPGET in Angular 6

I am currently working on an Angular 6 application that involves integrating the Google Javascript API with AGM. So far, the map functions well except for dynamically adding markers using an http get request. Here is a snippet of the component.html: < ...