*FIRST OFF, THIS POST IS VERY DIFFERENT 
FROM: 
https://groups.google.com/forum/#!searchin/angular/matrix/angular/3HaJChviUdo/HCjdEUvNyI4J
 
<https://groups.google.com/forum/#!searchin/angular/matrix/angular/3HaJChviUdo/HCjdEUvNyI4J>
 SO 
PLEASE DON'T MISUNDERSTAND AND MARK IT AS A REPEATED QUESTION*

Hi,

I need advice on building a matrix like such:

+---+------+-------+--------+-----+--------+
|   | MILK | BREAD | BUTTER | JAM | CHEESE |
+---+------+-------+--------+-----+--------+
|   |      |       |        |     |        |
| a | 1    | 0     | 1      | 1   | 0      |
|   |      |       |        |     |        |
| b | 0    | 1     | 1      | 1   | 1      |
|   |      |       |        |     |        |
| c | 1    | 0     | 0      | 0   | 0      |
+---+------+-------+--------+-----+--------+


*Introduction*

I'm trying to build an access control matrix with *checkboxes*.  Users 
click on a checkbox to grant certain LDAP groups (the column headings) 
access to certain resources (the row headings) in the webapp.  

*Problem*

I'm having difficulty wrapping my head around how to do this with Angular, 
making use of ng-model and ng-repeat.  I've done this using jQuery, but I 
want to know how this can be achieved in AngularJS implementations.  I need 
advice on the data structure of the data that gets returned from the server 
as well.  What should be the most ideal data structure to implement 
something like this with the least amount of pain.

*My attempt*

I have a data structure that gets returned from the server like so:

NOTE: I'm using the above table example here, not ldap groups.

{
    status: 200,
    payload: [
        {
            product: "milk",
            resource: "a",
            checked: true
        },
        {
            product: "bread",
            resource: "a",
            checked: false
        },
        {
            product: "butter",
            resource: "a",
            checked: true
        },
        ...
    ]
}



   1. I have control over the server response, so I am assuming the data is 
   "ordered" (notice how the objects in the array is ordered by row).
   2. What if the contents of the array are not ordered in any way?

I thought of adding a transform response to my angularjs $resource that 
would group the products in one array, and then ....... and then I just got 
stuck.  What should my ng-model be for the checkboxes?  How would my table 
be?

I created a plunkr:  http://plnkr.co/edit/ufbbvFxdn87GMCXOG1SN?p=preview 
<http://plnkr.co/edit/ufbbvFxdn87GMCXOG1SN?p=preview>

Above doesn't seem to work either.  

-- 
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/groups/opt_out.

Reply via email to