Angular: File2GUI_Add_More_Buttons

http://angularjs.org/

by rishi007bansod

HTML

<script src="http://code.angularjs.org/angular-1.0.0rc8.js"></script>
<script type="text/ng-template" id="tree_item_renderer.html">
	<div ng-show="!(data.name=='UserDictionaryRecord')">
  
  {{data.name}}<!--,{{data.functionToApply}},{{data.sel_option}},{{data.dummy}}-->
  
  
	<select ng-model="data.sel_option" 
  data-ng-options="optionTemplate as optionTemplate.name for optionTemplate in optionTemplates"
  ng-init="data.sel_option = optionTemplates[0]"
  ng-show="!(data.name=='UserDictionaryRecord')"
  >
    
</select>


  <select ng-model="data.functionToApply" 
  data-ng-options="blisterPackTemplate as blisterPackTemplate.name for blisterPackTemplate in blisterPackTemplates"
  ng-init="data.functionToApply = blisterPackTemplates[0]"
  ng-show="!(data.name=='UserDictionaryRecord')"
  >
    
</select>


	 Dummy: <input type="text" ng-show="!(data.name=='UserDictionaryRecord')" ng-model="data.dummy" value="" />
    
	</div>

  <ul>
    <li ng-repeat="data in data.nodes" ng-include="'tree_item_renderer.html'"></li>
  </ul>
</script>

<input type="file" id="files" name="files[]" multiple />
<output id="list"></output>

<div ng-app="Application" ng-controller="TreeController">
<ul>

  <li ng-repeat="data in tree" ng-model="json" ng-include="'tree_item_renderer.html'"></li>
</ul>
<button ng-click="expFile()">Export MetaFile2</button>

<textarea id="textarea1" cols="80" rows="10" ng-model="myTextArea" >
            </textarea>
</div>

CSS

ul {
  list-style: circle;
}

li {
  margin-left: 20px;
}

JavaScript

angular.module("myApp", []).
controller("TreeController", ['$scope', function($scope) {
  

  $scope.tree = [{
    name: "UserDictionaryRecord",
    functionToApply: "",
    sel_option: "",
    dummy: "",
    nodes: []
  }];

	var outDataString = "";
	function GenerateMetaFile(temp_tree, temp_parent_list, len){
  	
    //console.log('item isdafafafaf : '+temp_tree[0].nodes.length)
    	
    	for(var k = 0; k < len; k++)
      //for(var temp in temp_tree)
      {
      	list_copy_for_children = temp_parent_list.slice();
        list_copy_for_children.push(temp_tree[k].name)
      	//temp_parent_list.push(temp_tree[k].name)
        //for(var tt in temp_parent_list)
        if(temp_tree[k].sel_option.name == "this")
        {
        		console.log('inside this.................')
            for(i = 2; i < (temp_parent_list.length-1); i++ )
            {
            		outDataString = outDataString + temp_parent_list[i]+","
            }
            //Adding Outer Key....
            outDataString = outDataString + temp_parent_list[(temp_parent_list.length-1)]+",";
            //Adding Inner Key....
            outDataString = outDataString + temp_tree[k].name+",";
            //Adding Selected Function....
            outDataString = outDataString + temp_tree[k].functionToApply.name+",";
            //Adding Dummy Variable Value....
            outDataString = outDataString + temp_tree[k].dummy+"\n";
            
        		
        }
        else if((temp_tree[k].sel_option.name == "0")||(temp_tree[k].sel_option.name == "1"))
        {
                		console.log('inside 0/1.................')

        		for(i = 2; i < temp_parent_list.length; i++ )
            {
            		outDataString = outDataString + temp_parent_list[i]+","
            }
            //Adding Outer Key....
            outDataString = outDataString + temp_tree[k].name+",";
            //Adding Inner Key....
            outDataString = outDataString + temp_tree[k].sel_option.name+",";
        ...