PapaParse with Angular JS

后端 未结 4 592
我寻月下人不归
我寻月下人不归 2021-02-11 02:39

Liked the nice CSV parser & unparser of PapaParse. Can any one help me to get this combine with Angular JS.

I like to make PapaParse work in Angular Way. Trying for

4条回答
  •  甜味超标
    2021-02-11 03:08

    You can use value to provide self contained third party libraries.

    angular.module('your.app')
        .value('yourLib', yourLib);
    

    Then in your controller, or service, you would bring it in the normal way using DI

    angular.module('your.app')
        .controller('YourController', YourController);
    
    YourController.$inject = ['yourLib'];
    function YourController(yourLib) {
    
       //. . .  
    } 
    

    If the third party line is a constructor function, requires it be newed, you may want to create a factory or a provider that has a method that accepts the passes params to the constructor returns a new instance.

    Edit

    After looking at PapaParse, you would want to register it with the angular injector using value.

提交回复
热议问题