问题描述:

I have a rest web services was designed by mvc4 and angular js. Basically controller was AngularJs controller which is able to invoke webService(extends from apiController).

I have two pages, one page is login page, the controller is loginController.

The next page is customer page, the controller is customerController.

In the loginController, when user click login, the controller is able to read the user's information for example user's permission.

After login, the customer page will display some stuff according by the user's permission. But I dont know how to pass the permission from loginController to customerController.

Now, my approach is I tried to save the user's permission in the HttpContext.Current.Session["permission"], but it is seemed like angular js is not able to read data from HttpContext.Current.Session["permission"]. Unless, angular js is able to have a method to pass value from one controller to another.

网友答案:

Make a factory and add the permission to the factory object and inject to the customerController

app.customerController('factory',function(factory)){
}

something like this....

相关阅读:
Top