Generating Angular2 CLI components with Angular-Meteor integration

Exploring Angular2 CLI and Meteor has been an interesting journey for me. One thing I've noticed is that when I create a component using Angular2 CLI, integrating it into another module is as simple as including it in the declarations array of that module. https://i.sstatic.net/uuxX4.png

menu.component.ts

import { Component, OnInit } from '@angular/core';

import { MenuItem } from './menu-item';                                         
import { MENUITEMS } from './mocks';

@Component({
  selector: 'menu',                                                                                 
  templateUrl: './menu.component.html',                                         
  styleUrls: ['./menu.component.css']
})

export class MenuComponent implements OnInit {

  menuItems: MenuItem[];                                                                        

  constructor() { }                                                                                 

  ngOnInit() {
    this.menuItems= MENUITEMS;                                                          
  }                                                                                                                 

}

app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { RouterModule } from '@angular/router';

import { AppComponent } from './app.component';
import { MenuComponent } from './menu/menu.component';
import { HomeComponent } from './home/home.component';
import { TrendsComponent } from './trends/trends.component';
import { ControllerComponent } from './controller/controller.component';
import { WaterPlantComponent } from './water-plant/water-plant.component';
import { DocsComponent } from './docs/docs.component';

@NgModule({
  declarations: [
    AppComponent,
    MenuComponent,
    HomeComponent,
    TrendsComponent,
    ControllerComponent,
    WaterPlantComponent,
    DocsComponent
  ],
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule,
    RouterModule.forRoot([
      { path: 'home', redirectTo: '', pathMatch: 'full' },
      { path: '', component: HomeComponent },
      { path: 'trends', component: TrendsComponent },
      { path: 'controller', component: ControllerComponent },
      { path: 'waterplant', component: WaterPlantComponent },
      { path: 'docs', component: DocsComponent }
    ])
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

In my experience with Meteor, making it work required adding an index.ts file to the menu.component folder:

index.ts

import { MenuComponent } from './menu.component';

export * from './menu.component';

app.module.ts

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouterModule } from '@angular/router';

import { AppComponent } from './app.component';
import { PARTIES_DECLARATIONS } from './parties';
import { MenuComponent } from './menu/menu.component';

@NgModule({
  imports: [
    BrowserModule
  ],
  declarations: [
    AppComponent,
    ...PARTIES_DECLARATIONS,
    MenuComponent
  ],
  bootstrap: [
    AppComponent
  ]
})
export class AppModule {}

Could the difference in compiler "module" settings (ES6 for CLI and jscommon for Meteor) be causing this issue?

Any insights or suggestions would be greatly appreciated!

Answer №1

It seems that when using Angular CLI, you are adhering to the Angular2 style guide directory structure instead of following the Angular-Meteor directory structure, which suggests placing explicitly imported files in directories named imports. Due to Meteor's hybrid module system, is it possible that the default load order for files outside of imports directories in Meteor may be causing the issue? This could potentially be resolved by changing the load order for MenuComponent created by the export statement in index.ts.

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

What is the best way to include a variable or literal as a value in styled components?

When it comes to managing various use cases, I always rely on props. However, I am currently facing a challenge in changing the border color of a styled input during its focus state. Is there a way to utilize props for this specific scenario? Despite my f ...

Use Angular2 to showcase the selected image as the main one when the user clicks on the

I'm working on creating a product thumbnail gallery, and I'd like the main image to be displayed when the user clicks on a thumbnail. I am using Angular for this project, although I am still learning my way around the framework. product.html &l ...

Angular - obtain a secure reference to a lazily loaded DOM element

In my project, I have a specific template section that should only be present in the DOM when its corresponding object exists. In addition to this requirement, I need to access the form reference and attach an Observable using fromEvent('change') ...

Numerous attributes housed within a single element

In my project, I have set up a Store using Angular and NgRx 13. Within my SharedModule, I define components including selectors which load content into the store to prevent redundant API calls. https://i.stack.imgur.com/sr3nl.png This approach is impleme ...

Mongoose fails to add an object to an array

I am facing an issue with my express application where comments are not being inserted into posts. Even though there are no errors displayed, the comments are not being added when posting via Postman. I have tried various solutions like this and this, but ...

How to add Bootstrap and Font Awesome to your Angular project

After attempting to add Bootstrap and Font Awesome to my Angular application, I am encountering issues. I utilized the command npm install --save bootstrap font-awesome and included both libraries in the angular.json file as follows: "styles": ...

Retrieve the current number of displayed items from Ngx-Datatable

I have been utilizing swimlane/ngx-datatables in combination with Angular5. I am interested in incorporating a new footer that showcases the current display count. https://github.com/swimlane/ngx-datatable Here is my desired format for the footer: Showing ...

The image located in the wwwroot directory is not displaying when the <img> tag is used. What could be causing this issue in ASP.NET and Angular?

My current project is housed in a folder named 'UsedCarsShop', which contains two subfolders: Frontend Within this folder is the 'UsedCarsShopFrontend' folder, where the Angular project is located. Backend The 'CarWebShop&apos ...

Activate the reactive forms when the checkbox is selected

Can you help me with enabling rows only when the checkbox is checked? I want the default rows to be disabled, but when the checkbox is checked, that specific row should become enabled. Here's the link to my code: CHECK OUT THE CODE HERE updateValu ...

Issue during deployment: The type 'MiniCssExtractPlugin' cannot be assigned to the parameter type 'Plugin'

I'm working on deploying a Typescript / React project and have completed the necessary steps so far: Created a deployment branch Installed gh-pages for running the deployed application Added a deploy command as a script in the package.j ...

The e2e Protractor test is unable to identify the Angular component within a complex Angular router with multiple layers

I am currently working on an Angular application and I need to set up end-to-end testing for this project. Angular Package: 4.6.6 Protractor: 5.3.0 In addition, my project includes a multi-layer router that wraps the router-outlet into another component ...

Dealing with multiple validation error messages in Angular Material 2

Working on a form using Angular Material 2, I am implementing a template-driven approach with an email input that requires two validators: required and email. The documentation for the input component (available at https://material.angular.io/components/co ...

How can I invoke the header component function in another component using Angular 2?

Is there a way to invoke the showmodel(displayType) function from another component? How can I call a function in the header component from a different component? header.component.ts import { Component,Renderer } from '@angular/core'; i ...

Creating a stacked chart in Angular using chart.js with JSON array of objects values

I am currently working on implementing a stacked chart using chart.js, and I have encountered some challenges: I am struggling to display currency values in the correct format on the chart (the height of the bar is not visible when passing amounts). How c ...

The embedded component is throwing an error stating that the EventEmitter is not defined in

Currently, I am delving into the realm of angular and facing an issue. The problem lies in emitting an event from a component nested within the main component. Despite my efforts, an error persists. Below is a snippet of my code: import { Component, OnIn ...

Is it possible to reduce the number of calls to ngAfterContentChecked() and ngAfterViewChecked() instead of calling them repeatedly?

`ngAfterContentChecked() { console.log("Content has been checked"); } ngAfterViewChecked(){ console.log("View has been checked"); }` I am currently developing an Angular project where I need to execute a set of statements twice on a page - ...

The 'undefined' type cannot be assigned to the 'never' type

interface A { name?: string age: number } var a: A = { name: '', age: 23 } var result:A = (Object.keys(a) as Array<keyof A>).reduce((prev, key) => { if (a[key] || a[key] === 0) { prev[key] = a[key] // an error was reporte ...

The entry for "./standalone" in the "@firebase/database-compat" package does not have any documented conditions

Upon running npm run build for my sveltekit project, I encountered the following error generated by vite: 7:55:49 PM [vite-plugin-svelte] When trying to import svelte components from a package, an error occurred due to missing `package.json` files. Contact ...

You cannot call this expression. The type 'String' does not have any call signatures. Error ts(2349)

Here is the User class I am working with: class User { private _email: string; public get email(): string { return this._email; } public set email(value: string) { this._email = value; } ...

Exploring ways to fetch an HTTP response using a TypeScript POST request

I have been looking at various questions, but unfortunately, none of them have provided the help I need. The typescript method I am currently working with is as follows: transferAmount(transfer: Transfer): Observable<number> { return this.http .po ...