Welcome Guest, Not a member yet? Register   Sign In
Should data be manipulated in the controller or is it "View"'s job
#1

(This post was last modified: 08-05-2016, 10:08 PM by rliy001.)

    [attachment=658][attachment=658]Hi there,

New to CodeIgniter. 
Hoping to use AngularJS on the Views and Code igniter for back end.


I'm wondering whether to touch and manipulate the data in the controller/ get it into the required format before passing it on to the view
OR not do anything in the controller and simply pass the data to the view so it becomes AngularJS's problem.

On one particular case, data is fetched from the database in one query and returned in a single array like so...

Season              Grade      RoundDate        Time      GameID         Team1        Team2      Team1Score       Team2Score  
------------------------------------------------------------------------------------------------------------------------------------------
Winter 2016     MENS 1      5 Aug             10:00            1              TEAM A      TEAM B       110                     140
Winter 2016     MENS 1      5 Aug             11:00            2              TEAM C      TEAM D       130                     110
Winter 2016     MENS 1      1 Aug             10:00            3              TEAM B      TEAM C       95                       120
Winter 2016     MENS 1      1 Aug             11:00            4              TEAM A      TEAM D       95                       120
Winter 2016     MENS 1      24 Jul             10:00            5              TEAM A      TEAM D       75                       107
Winter 2016     MENS 1      23 Jul             10:00            6              TEAM B      TEAM C       110                     140


Controller simply passes this data to the view in a single array $data

In the view I would like my data to display like below. As you can see the data is grouped by a several columns so I'm a little lost as to whether it is Angular's job to do this grouping and display on the page or whether I should touch the data in the controller and somehow return the data to the view in several arrays representing each of those grouped sections... or whether I should make multiple calls to the database to fetch each of the required data sections on the fly. Or a completely different approach that I have overlooked. Little help?

-------------------------------------------------
WINTER 2016 - MENS 1

-------------------------------------------------
5 AUG 2016

10:00 TEAM A  100 - 120 TEAM B
11:00 TEAM C 150 - 90 TEAM D


-------------------------------------------------
1 AUG 2016

10:00 TEAM B  111 - 87 TEAM D
11:00 TEAM A 89 - 90 TEAM C

-------------------------------------------------

25 JUL 2016

10:00 TEAM A  111 - 87 TEAM D


-------------------------------------------------
23 JUL 2016

10:00 TEAM B  111 - 87 TEAM C



I have attached how my data is currently rendered by AngularJS. As you can see it is currently displayed as a flat table. No groupings present
Reply


Messages In This Thread
Should data be manipulated in the controller or is it "View"'s job - by rliy001 - 08-05-2016, 05:57 PM



Theme © iAndrew 2016 - Forum software by © MyBB