HI, 
It's my first time trying to build something with angular , and i find 
myself not able to retrieve some JSON data.  

The data is retrieve from a SQL database in JSON form then passed to a 
template thanks to  angular route : 

.when('/tasks/:TaskID',{
templateUrl: 'template/task_data_template.html',
controller:"showTaskData",
controllerAs: 'STD'
})

The showTaskData is defined as follow : 

    
angular.module('moonDive').controller('showTaskData',function($http,$routeParams){

var store = this; 

store.tasks= [];

json_Url = 'api/tasks_data.php?TaskID=' + $routeParams.TaskID;


$http.get(json_Url).success(function(data){
store.tasks = data; 
    })});

My Data have this structure : 
http://i.stack.imgur.com/LRamn.png

This is accessible from the template html by : 

    {{STD.tasks[1]}}

Which return the data in that "JSON" way :

    {
        "ActionID": "1",
        "Taskref": "1",
        "Ast1_1": "",
        "Ast2_1": "Start EVA watch\nopen           hatch\nAssist CDR",
        "Ast3_1": "",
        "Ast1_2": "Egress cabin to LM porch\nReceive &      jetttison 
bag\nReceive ETB/LEC",
        "Ast2_2": "Deploy CDR PLSS antenna\nHand jettison      bag to 
CDR\nHand ETB/LEC to CDR",
        "Ast3_2": "",
        "Ast1_3": "Descend lander to top rung\nUnlock and deploy 
MESA\nLower ETB on LEC",
        "Ast2_3": "Tape recorder -off\nVerify voice signals level and 
uitlity floo [......]"
    }

So far so good, so my final purpose is to have a table with two column 
(ast1 , ast2) and X row for X task. I'm not really sure how to begin , but 
i've tried something like that : 

    <table class="bordered hoverable responsive-table">
    <tbody>
    
    <tr ng-repeat="boo in STD.tasks[1]">
    <td style=" color: blue;" ng-if="$odd"> {{boo}}</td>
    <td style="color:red" ng-if="$even"> {{boo}}</td>
    </tr>
    </tbody>
    </table>
Well no luck it doesn't work at all, but one weird thing that prevent me to 
understand what's going on is that it displays all the information but in 
what seems to be a random order.


http://i.stack.imgur.com/StAIu.png



I'd like to delete rows with "1" ; usually i would do a 
ng-if="boo.NameOfTheRow" ;  but here i don't really have access to this 
name do I ? 

So my question is : How to delete the unnecessary data?  And how can I 
 arrange my data by Astr1 and 2 (for the columns) and task 1 to X (for the 
rows)

Thanks a lot ! 

PS : 
The generated code should look like that : 

    <table>
    
    <thead>
    <td> task </td>
    <td> Astr 1 </td>
    <td> Astr 2 </td>
    <td> Astr 3 </td>
    </thead>
    
    <tbody> 
    <tr>
    <td> 1</td>
    <td> {{STD.tasks[1].Ast1_1}} </td>
    <td> {{STD.tasks[1].Ast2_1}}</td>
    <td>{{STD.tasks[1].Ast3_1}}   </td>
    </tr>
    <tr>
    <td> 2</td>
    <td> {{STD.tasks[1].Ast1_2}} </td>
    <td> {{STD.tasks[1].Ast2_2}}</td>
    <td>{{STD.tasks[1].Ast3_2}}   </td>
    </tr>
    
    <tr>
    <td> 3</td>
    <td> {{STD.tasks[1].Ast1_3}} </td>
    <td> {{STD.tasks[1].Ast2_3}}</td>
    <td>{{STD.tasks[1].Ast3_3}}   </td>
    </tr>

    ....
    <tr>
    <td> 7</td>
    <td> {{STD.tasks[1].Ast1_7}} </td>
    <td> {{STD.tasks[1].Ast2_7}}</td>
    <td>{{STD.tasks[1].Ast3_7}}   </td>
    </tr>


    </tbody></table>
 
Thus the data should be displayed as : 
http://i.stack.imgur.com/0IwlE.png


PS: this post has been first written on Stack OverFlow 
: 
http://stackoverflow.com/questions/31053127/angular-js-sub-array-access-parsing-a-key

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to