Today we will create a sample application to use dynamic button with partial view. Let’s create a sample MVC application & apply the below code snippets.

We need to create a partial view which will render in different pages.

Common View(Button):

Students View:

Teachers View:

Our views are created now we will add some behavior using angular script. Here we have individual collection of permission & function name along with differentiate by angular controller.

Student JS: Now it is using stdCtrl collection to generate button on Teacher view along with it’s permission.

Teacher JS: Now it is using cmnCtrl collection to generate button on Teacher view.

A common controller also added to behave the button with same collection all over the application.

Common JS:

Finally: The view is now generating the dynamic button with same partial view in each page.

ng-btn-1 ng-btn-2

Source Code: I’ve uploaded the full source code to download/clone @github, Hope this will help 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *