Skip to content

Allows copy paste of tabular data from a spreadsheet into a webpage, updating any specified models

Notifications You must be signed in to change notification settings

lukegardiner/angular-paste

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Use as you please.

You need to create your strategy object like shown below:

var MyStrategy = function() {
      
     	//The Regex to split data into actionable items
	    this.pattern = function() {	    
	        return /[\n\f\r]/;
	    };

      	//The action per item to return one row of data
	    this.action = function(item, $scope){
	    	//You could even return selected colums like the following
	    	/*
	    	//We will select some columns to return
	    	var selectedData = [];

	    	//The parsed data from the paste
	    	var parsedData = item.split("\t");

	    	//Below we add the 1st and third column from our data
	    	selectedData.push(parsedData[0]);
	    	selectedData.push(parsedData[2]);

	    	//And return it.
	    	return selectedData;
	    	*/
    		return item.split("\t");
	    }
     
      	//The function that will be called after all the actionable items are processed
	    this.finish = function(item, $scope){
	    	console.log("finish", item);
	    }
	};

In your scope you need create a function to set the strategy:

$scope.StrategyA = function(){
	return new MyStrategy();
};

And add this to your HTML file:

<angular-paste ng-model="rawPaste" ng-array="parsedPaste" ng-strategy="StrategyA()"/>

Add this directive in your Layout page:

<script src="js/directives.js"></script>

Visit this jsfiddle below to see this directive in action:

Visit jsfiddle!

About

Allows copy paste of tabular data from a spreadsheet into a webpage, updating any specified models

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 78.9%
  • HTML 21.1%