lundi 18 avril 2016

AngularJS - Strategy Design Pattern?

Is there a clean way to implement the strategy design pattern or something like it in AngularJS? I am basically building up a dashboard, but there are different user levels in my system. So some will have different dashboards, which require different functions and whatnot.

What I was looking to do is swap out the controller based on the user's access level. I would have something like a baseDashboardCtrl for the common things, then using angular.extend(), I would create their respective "extended" dashboard controllers with the different data and functions. I suppose I'll create different partials too, but I know how to do that.

I'd like to go this route so that I don't fill up a single controller with all this code, when it's not going to be needed for some access levels.

Aucun commentaire:

Enregistrer un commentaire