javascript-bower_component jquery plugin is not called in angularjs app
Overview
I have several jQuery plugins that I intend to use in an AngularJS application. I install my jQuery plugins through bower. I use gulp-inject to put these dependencies into the main html. I load jQuery first, then Angular. Prepare a template and organize it similar to John Papa's Hot Towel AngularJS generator.
problem
Libraries intended to extend jQuery are not being called. These files are loaded, but never extended on jQuery. For example, use the following two jQuery plugins: remarkable-bootstrap-notify and jquery.sparkline. When these two jQuery plugins are loaded into the page, I get an error stating that one of the functions I'm calling from these libraries doesn't exist.
what i tried
If I put a breakpoint in the file loaded in the browser, I'll notice that the above factory code is indeed called, but the code that does the extension (adding new functionality) is not running. If I pass before adding ... }(jQuery) )) to change the extraordinary Bootstrap notification file loaded in my page, and suddenly the library starts working.
I tried the same fix on the jquery.sparkline library, but that doesn't make the library work.
Obviously, this is not the ideal workaround, because the next time I bring in the library via bower, my changes no longer exist, breaking the functionality of applications that depend on these libraries.
Notice
I'm trying to use these jQuery plugins in a directive. It's not pre-emptive, but I've been reading all over the place that this is how to solve a problem for someone similar to myself. However, it makes no difference to me.
Updates
I've now applied this"fix"to 3 libraries, which temporarily solved the problem (jquery.sparkline, jquery.easypiechart, and bootstrap-notify). My question now has a more specific update, which hopefully will be answered.
problem
It doesn't seem easy to have an AngularJS app with a jQuery plugin dependency, but I think it's easy. What am I missing that would normally allow it to work? Is there anything I can do to resolve all these dependencies I'm introducing via bower?
Updates
I now have 3 libraries in my bower_components folder that need to be edited manually to use. Graphically speaking, I had to add the following (highlighted in the image below) to get the libraries to work properly in my application:
(This is just an example shown at the top of these typical jQuery plugins)
Paraphrasing the question: I'm more specific than"I'm calling an anonymous function, passing a jQuery object as a parameter"when I add...(jQuery)... I get it. But, why isn't this file included in the library I downloaded via Bower? Will my application force me to make these manual edits? This is not how these libraries are usually used...
Solution:
Quick question: what jQuery plugin are you talking about? Why try to hack jQuery code into Angular, where you can usually find the same or better plugins already written for Angular.
Extraordinary bootstrap notifications can be replaced with AngularJS-toaster
jquery.sparkline can be replaced with Angular-chart
This is from docs.angularjs.org:
DOM manipulation
Stop trying to use jQuery to modify the DOM in the controller. True. This includes adding elements, removing elements, retrieving their contents, showing and hiding them. Use built-in directives, or write your own if necessary to do DOM manipulation. About the copy function , see below.
If you want to break the habit, consider removing jQuery from your application. True. Angular has a $http service and powerful directives that make it almost always unnecessary. Angular's bundled jQLite has some of the most important features when writing Angular directives Commonly used functions, especially binding to events.
javascript-bower_component jquery plugin is not called in angularjs app Related posts
- python- Combine multiple time series data into a 2d numpy array
I have time series data from three different sensors during the year, these sensors produce a data point approximately every 3 minutes, the sensors are not synchronized, so they produce a data point output at a different time relative to each other.The data is in the sqlite db of a table with about ...
- javascript-pass the schedule to the onClick event Redux
I'm working on my first react/redux application and I have a lot of troubles when mapping dispatch actions to onClick events in components.I have tried several variants that try to bind onClick Event to dispatch, but I always end up in either of the following two situations:ReferenceError: onMovieCl ...
- c#-use the default convention one-to-one relationship with optional dependent end
I want to use the default conventions in the Entity Framework code-first model to map a subject entity (person) and optional dependent entity (car).A solution is described in this answer that uses the fluent API on modelBuilder to map to the key.Is it possible to do this using only the default EF co ...
- php realizes obtaining accurate age based on ID card
Sometimes, we want to calculate the age through the ID card, so the function I wrote below is very suitable.There are detailed comments in the implementation code.function getAge($id){# 1. Obtain the date of birth from the ID card $id = $id;//ID card $birth_Date = strtotime(substr($id, 6, 8));//The ...
- c#-How to use the sendkey method to send the ALT SPACE key?
I am implementing a desktop application in which I want to send the ALT SPACE key combination, but I can't find any way to do this.I am implementing this to automatically handle the following tasks:> Enter the tracert command at the command prompt > copy the result > paste the result in the ...
- In-depth analysis of the matching process of Python regular expressions \W+ and \W*
In the process of learning the re.split function, it was found that the execution and return of the following statements were inconsistent with what the old ape had expected:>>> re.split('\W*','Hello, world')['','H','e','l','l','o','','w', 'o','r','l','d','']What the old ape expects is ['', ...
- Six Principles of Object-Oriented Programming
1. Open Close PrincipleThe principle of opening and closing means: open to expansion and closed to modification . When the program needs to be expanded, the original code cannot be modified to achieve a hot-swappable effect. In short, it is to make the program extensible, easy to maintain and upgrad ...
- javascript-After loading the HTML content into the DIV, adjust the size of the color box
I have ventured here on any and all posts about colorbox resizing issues, div attributes and many other things! Anyway, this very simple code is pushing me to the wall, I wonder if it is unanswerable?The above is the code (I think-should work like a charm). I tried using $.get and put the resize in ...
- javascript-Typescript and AngularJS 1.5: How to deal with export classes
I have this module.ts file:import {IHttpService, IPromise} from'angular';export class ProductService {static $inject = ["$http"]; constructor(private $http: IHttpService) {} loaded: boolean = false; promise: IPromise<{ data: any }>; getProducts(): IPromise<{ data: any }> {if (!this.loade ...
- c#-Unity3D-Find the floating point average value per second
I am calculating the speed and it works well. But how do I find the average value of the speed variable? The speed value changes approximately once per second (when the GPS value is updated). When he (she) presses the"Done"button, I need to display the user's average speedthank you for your helpThis ...
Recent Posts
- Excerpts from domestic algorithm books
IOriginal title: Chinese name: Algorithm and data structure Author: Fu Qingxiang and Wang Xiaodong Difficulty: *** Personal evaluation: **** Recommendation: **** This is one of the best data structure algorithm books written by Chinese One, it is very detailed. The last three chapters: complexity, p...
- php-the callback function returns return($var&1)?
I have read PHP Manuel about array_filter1,"b"=>2,"c"=>3,"d"=>4,"e"=>5);$array2 = array(6, 7, 8, 9, 10, 11, 12) ;echo"Odd :\n";print_r(array_filter($array1,"odd"));echo"Even:\n";print_r(array_filter($array2,"even"));?>Even if I see the result here:Odd :Array( [a] => 1 [c] => 3 [...
- php performance optimization
Reprinted for learning1. Try to be static:If a method can be static, then declare it as static, the speed can be increased by 1/4, even when I tested, this increased by nearly three times. Of course, this test method needs to be executed at the level of 100,000 or more for the effect to be obvious. ...
- c#-How to get the app.config of other applications and modify it
I have two windows applications. For example, FormA and FormBThe app.config of FormA looks like thisNow I have another application called Form B.I want to retrieve the appsettings and connectiontrings of form A to form B.In addition, I should be able to modify these appsettings and connection string...
- java – Spring boot: How to read resources from the classpath in a unit test
I am trying to read a file from the classpath in my unit test:@Value("classpath:state.json")Resource stateFile;I have the state.json file in the src/test/resources directory. When I try to read this file using stateFile.getInputStream(), it returns nothing. What am I doing wrong?My test class is ann...
- java-Hibernate will not create tables-Spring MVC
I have a spring project and I am using hibernate. When I start the project, the db does not change.I tried the difrenf configuration but it didn't work.What idea could be wrong?Hibernate is configured in servlet.xml:com.springapp.mvc.modelorg.hibernate.dialect.HSQLDialectupdatefalseSolution:usecreat...
- How to use pause, thread (task, service) simulation queue and stack JavaFX
I have been searching YouTube, Stack-Overflow and fxexperience, and even the oracle documentation, but I still don't get it. Is there any similar example :(The question is how to make stack and queue simulators.> Generate 10 random numbers. Done. > Display the numbers in the table. Done. > ...
- PHP-Differences between two soap requests
My SOAP requesturn:uuid:7C2F61BDE7CB9D9C6D14249385687242015-02-22T00:00ZExpected SOAP requesturn:uuid:479731898147E116AD14246915189682015-02-22T00:00ZTry to use the following code:$options = array('trace' => 1,'exceptions' => 1,'soap_version' => SOAP_1_2 );$client = new SoapClient("http://d...
- Python3 basic getattr Get the specified attribute value of the object
    Python: 3.7.0      OS: Ubuntu 18.04.1 LTS      IDE: PyCharm 2018.2.4     Conda: 4.5.11   typesetting: Markdowncodec[email protected]:~$ source activate py37(py37) [email protected]:~$ ipy...
- all the knowledge points related to the agent in Java are gathered here, and learn quickly.
For every Java developer, the term agent will be heard more or less. You may have heard of proxy mode, dynamic proxy, reverse proxy, etc. So, what is an agent, and what is the difference between so many agents? This article will briefly analyze.Proxy technology is not just a technology specific to t...