Error when integrating template to Angular 7

Asked

Viewed 76 times

0

Hello, I have a problem: I am integrating a template that works on jQuery, css3 and Html5. I added it to node_modules and referenced the scripts in angular.json. The template css is working normally, but no javascript/jquery function is working, anyone can help me?

Referencing :

"scripts": [
          "node_modules/altair/bower_components/jquery/dist/jquery.min.js",
          "src/assets/assets/js/uikit_htmleditor_custom.js",
          "src/assets/bower_components/uikit/uikit.js",
          "src/assets/assets/js/common.min.js",
          "src/assets/assets/js/uikit_custom.min.js",
          "src/assets/assets/js/kendoui_custom.min.js",
          "src/assets/assets/js/altair_admin_common.min.js"
        ]
  • Read it here: https://answall.com/questions/411207/comort-menu-dropdown-no-angular-com-materialize-css?noredirect=1#comment803260_411207

  • Good afternoon, I already gave a read and tried applying this method, but it didn’t work. Nothing using the template’s main.js file is working....

1 answer

0

To use the jquery

 npm install jquery --save

at the angular.json

"scripts": [ "../node_modules/jquery/dist/jquery.min.js" ]

To use Jquery, you must import in any Component you wanted to use

import * as $ from 'jquery';

This example uses the app-rot in your Komponent

import { Component, OnInit  } from '@angular/core';
import * as $ from 'jquery';
@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {


  public ngOnInit()
  {
    //jQuery code
        });
    });
  }
}

take a look at official documentation

  • I’ve done all this, the jquery itself is working, but the code of my template does not work. No event works, sidebar doesn’t work, nothing, nothing... it’s complicated :/

  • can you pass me the repository code on github? what low and help you solve

  • The template is giant, has lots of code... you have some means to contact?

  • I deployed the project: https://github.com/andrerebonato/error-angular

  • Package.json is missing from the repository you submitted

  • you can start a new project and import bower_components and Assets from the src/Assets folder ??

  • yes... the way you put it even... in the.json angular scripts, if you put the scripts, you don’t have to import at index.html... ex: "scripts": [ "src/Assets/bower_components/Moment/Moment.js"]

  • So, but unfortunately it didn’t work either way, you did it?

  • Actually, I was able to import some of the dependencies, but the bower_module folder does not have some others. I had problems mainly with the codemirror. I’ll investigate further and I’ll tell you if I can

  • All right, I’m on hold, mate, so far I haven’t been able to solve either...

  • Where did you download this template? Suddenly some documentation could help, or even the original version. I saw that you already have some Bower dependencies, but index.html refers to libraries that are not available in bower_components. This is the original template?

Show 6 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.