Problem with scope of Angular Components 2 with the import of external Javascripts

0

I have a problem and I believe the same is related to the scope of Components in Angular 2.

First, I would like to comment on the division of the project. It is divided into five components, the App, Menu-left, Menu-header, Content and Footer-Component.

Index:

<html>
  <head>
    <meta charset="utf-8">
    <title>Frontend</title>
    <base href="/">
    <meta name="viewport" content="width=device-width, initial-scale=1">
  </head>
  <body class="nav-md">
    <div class="container body">
        <div class="main_container">
          <app-root></app-root>
        </div>
    </div>
  </body>
</html>

The <app-root></app-root> is the main one and consists of the modules:

app.component.ts:

<menu-left></menu-left>
<menu-header></menu-header>
<content></content>
<footer-component></footer-component>

Within each one there is HTML content that will be presented to the user, with the menu at the top (menu-header), a menu on the left (menu-left), etc ...

The problem I am having is regarding Javascript loading in the presentation of this data, ie Javascripts work for Menu-Header , in which a menu drop-down with 100% effects is displayed. However, the same does not occur for Menu-Left , where there is also a menu drop-down .

What I tested was this: I put all the HTMLs (from the menu-left, menu-header, content, footer) and inserted them directly into the main page ( index.html ) and the most frustrating thing was that everything worked, with 100% of the effects loaded from the Javascripts that I imported.

It's worth mentioning that I'm using Angular-CLI and I'm importing Styles and Javascripts as follows:

angular-cli.json:

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "project": {
    "name": "frontend"
  },
  "apps": [
    {
      "root": "src",
      "outDir": "../../../target/frontend",
      "assets": [
        "assets",
        "favicon.ico"
      ],
      "index": "index.html",
      "main": "main.ts",
      "polyfills": "polyfills.ts",
      "test": "test.ts",
      "tsconfig": "tsconfig.app.json",
      "testTsconfig": "tsconfig.spec.json",
      "prefix": "app",
      "styles": [
        "../node_modules/gentelella/vendors/bootstrap/dist/css/bootstrap.min.css",
        "../node_modules/gentelella/vendors/font-awesome/css/font-awesome.min.css",
        "../node_modules/gentelella/vendors/iCheck/skins/flat/green.css",
        "../node_modules/gentelella/vendors/bootstrap-progressbar/css/bootstrap-progressbar-3.3.4.min.css",
        "../node_modules/gentelella/production/css/maps/jquery-jvectormap-2.0.3.css",
        "../node_modules/gentelella/production/less/custom.css"        
      ],
      "scripts": [
        "../node_modules/gentelella/vendors/jquery/dist/jquery.min.js",
        "../node_modules/gentelella/vendors/bootstrap/dist/js/bootstrap.min.js",
        "../node_modules/gentelella/build/js/custom.min.js"
    ...
      ],
      "environmentSource": "environments/environment.ts",
      "environments": {
        "dev": "environments/environment.ts",
        "prod": "environments/environment.prod.ts"
      }
    }
  ],
  "e2e": {
    "protractor": {
      "config": "./protractor.conf.js"
    }
  },
  "lint": [
    {
      "project": "src/tsconfig.app.json"
    },
    {
      "project": "src/tsconfig.spec.json"
    },
    {
      "project": "e2e/tsconfig.e2e.json"
    }
  ],
  "test": {
    "karma": {
      "config": "./karma.conf.js"
    }
  },
  "defaults": {
    "styleExt": "css",
    "component": {}
  }
}

I would like a suggestion that can help me find this problem that I believe is 'scoped', because it was what made me the most.

Thanks!

    
asked by anonymous 24.05.2017 / 04:57

0 answers