jquery - How to use a third party js in Angularjs -
i want use third party js file (not written in angularjs) service in angularjs controller. able use js in html inside script> tag want use functions in controller. there way include js file inside controller service or other way?
you can create new service in angular this
angular .module("app") .factory("jsservice", function () { // here goes code of js (d3 in case) //now return object of service return d3; }
and can inject service controller , use it
**update : ** click button , can log d3 service ,, , can use inside angular ,,
https://jsfiddle.net/rzkku08r/
**update : ** can inject jquery self service ,, , add plugin ,, did d3 ,, can see added d3 service , before returning added code of 2 plugins (word cloud jason davies) , (d3.tip) , returned service containing (d3 , plugins) , can use them every in app ,,
Comments
Post a Comment