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.

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

Integrate worldwide sass into Angular 4 using webpack

I'm facing an issue with my Angular 4 project that uses webpack with HMR. Just to note, I am integrating it with ASP Core 2 using the angular template. My goal is to create a global/main SCSS file that will be applied to all components. I want this S ...

Issue deploying Angular 2 and Rails 5 on Heroku: npm command not found in bash

After successfully deploying an Angular2 on Rails5 app to Heroku and setting up the PG database, I encountered a stack trace in the Heroku app log indicating that the npm command was not found. This error has been perplexing as I try to troubleshoot the is ...

Issue with displaying MP4 movies in Angular

I'm trying to display an mp4 video in Angular 9: <video controls (click)="toggleVideo()" preload="none" *ngIf="post.moviePath != null" #videoPlayer> <source [src]="getMovieSanitazePath(post.moviePath ...

Using PHP encryption and decrypting with AES in Angular using Crypto-JS

I have successfully implemented encryption and decryption in PHP using aes-256-cbc. However, I am now facing a challenge in decrypting the same content in Angular 7. Encryption in php using aes-256-cbc by following method $this->data ="plaintext&qu ...

Having trouble running ng e2e on TeamCity with an @angular/cli script that refuses to cooperate

While using TeamCity 10, I encountered an issue with running an @angular/cli project during a build step. Everything worked smoothly until the e2e script was executed, causing the build to halt and require a forced shutdown. To troubleshoot, I accessed my ...

Issue with Angular 5 EventEmitter causing child to parent component emission to result in undefined output

I've been trying to pass a string from a child component to its parent component. Child Component: //imports... @Component({ selector: 'child', templateUrl: './child.component.html', styleUrls: ['./child.c ...

Angular: Effective communication between components through routing and Observable binding ultimately results in the advancement of ngtsc(233

I designed an Angular Component named "crear-pedido" that exhibits a catalog of items (using row of products) and my aim is for the user to have the ability to click on the values in the ID column and navigate the application to a subordinate component kno ...

Developing an Observer and sending updates to my followers

I have a function that returns an Observer for subscription. Inside this function, I make an API call which also returns an Observer to which I subscribe. Once I analyze the data received from this Observer, I need to notify my own Observer subscribers. B ...

Angular fails to retrieve the data from an Object

I have both backend and frontend applications. When I attempt to retrieve information about the 'Probe' object, I can see its fields: https://i.stack.imgur.com/TJQqI.png However, when I try to access this information in Angular, I receive an und ...

Tips for incorporating nested generics in Typescript

Currently, I am developing a straightforward activity execution framework that allows developers to define activities which can be executed within a workflow. To enhance type safety and boost developer productivity by utilizing type hints, I aim to incorp ...

Dynamic value for href in div using Angular

Implementing a dynamic submenu using Angular is my current project. At the moment, I have set the href attribute with hardcoding as shown below: <ng-template #preSelectionMenuItem let-preSelections="preSelections"> <div class=' ...

Error message: When working with Protobuf, an uncaught reference error occurs because the 'exports

Currently, I am in the process of configuring protobuf to work with typescript. According to the official Google Documentation, all that is needed is to execute npm install google-protobuf and then to include require('google-protobuf'). Unfortu ...

Issue with ngSubmit not being triggered in Angular Reactive Form

Just jumping into Angular and experimenting with reactive forms while following a tutorial. Struggling to get my ngSubmit() function to work - the submit button doesn't respond no matter what I try. Spent ages trying to troubleshoot but no luck so far ...

Steps for developing a Global service in Angular

I've come across many discussions on global angular services, but none seem to truly embody the concept of "global". I'm curious if it's feasible to develop a service that doesn't require importing everywhere it's used (i.e. truly ...

event activated when the input file is prepared for utilization by the browser

Which event should be used in conjunction with <input type="file"> to receive notification when the browser is ready to use the selected file? Once the user clicks on <input type="file"> and selects a file, I want to utilize that file within t ...

Incorporate an external library

I am currently facing a challenge in my angular2 project where I need to import a 3rd party library. Here are the steps I have taken so far: ng new myproject npm install --save createjs-easeljs npm install @types/easeljs However, I am stuck at this poin ...

Implementing Limited Results in Redis FT.SEARCH with TypeScript

Snippet of code: client.ft.SEARCH('license-index-json',"@\\$\\" + ".reservedForApplicationName:GSTest",{ LIMIT: { from: 0, to: 1 } }) Error message: An error occurred when trying t ...

Utilize TypeScript to access scope within a directive

Is there a way to access the controller's scope properties using my custom TypeScript directive? For example, in this snippet below, I am trying to retrieve and log scope.message: /// <reference path="typings/angularjs/angular.d.ts" ...

Trouble occurs in the HTML code when trying to access a property from an inherited interface in Angular

Currently, I am working with Angular 17 and have encountered a specific query: In my project, there is an IDetails interface containing certain properties: export interface IDetails { summary: Summary; description: string; } Additionally, there is an ...

Having trouble with Angular's ng-tags-input? Are you getting the error message "angular is not defined"? Let

I recently created a new Angular project using the following command: ng new "app-name" Now, I'm attempting to incorporate ngTagsInput for a tag input feature. However, every time I try to build and run my app, I encounter an error in my browser con ...