javascript - AngularJS - Conditionally set a controller for the route -
i'm using native angularjs router , wondering if there way assign controller route conditionally. example, let's have 3 user types:
- guest
- user
- system admin
when come home page, want able assign different controller based on user type. have 3 registered controllers: guesthomectrl
, userhomectrl
, systemadminhomectrl
.
i imagined this:
$routeprovider .when( '/' , { controller: gethomectrl(), controlleras: 'homectrl' })
i know can pass in string of registered controller, main issue being able find out type of user logged in. have userservice
typically keeps track of that, doesn't seem can access set routes. or mistaken?
any direction out lot.
check this article of dan wahlin.
he explains how achieve near question.
Comments
Post a Comment