Friday, December 11, 2015

Day 38

AngularJS Associations


I thought the AngularJS assignments were pretty easy until we started associations. Before, we would just have an array that is our "database". Oh, one thing that should be mentioned is that all the assignments are done in just Angular. Nothing is being done with the other 3 parts of MEAN. Now, originally all the items in the array of objects only had one value per key. But with associations, there can be key with an array value that holds multiple values in itself. 

There is a workaround that you can do; whichever information that is being displayed, you can just push information into that factory. Imagine you can add users and teams. But you have to associate the users into teams and you can only have one team per user. But a team can have multiple users. The proper way to do this assignment is to add a team field to your players list in your player factory and then a users array in your team factory. But on the associations partial, you need to just show all the users that are currently existing and associate teams with them. So my workaround to this correct way is to add a team to the players and that was it. 

However on the next assignment that Kris gave us, it was basically the same thing but with users and parties and we had to work in groups so I did learn how to do it the proper way.

No comments:

Post a Comment