Home>

Foreword

If i want to dynamically load a content in angularjs,Then we can use ng-include to achieve it. Today insus.net is in the asp.net mvc environment, for example to demonstrate its function.

Example introduction

You can load any other view dynamically in one view.If your dynamic content has many parts,You need to create corresponding action actions in the controller. For example, you do not need to create corresponding actions when using partial view. So this is what insus.net likes.

In addition, we need to take some parameters for the ng-include link! !! !!

Therefore, the parameters are implemented using the model:

Because of the ng-include link, give some view names or paths directly,Views cannot render some views directly.

Then we think of a way,Write a public view,All partial views can be loaded in this common view,Use this common view to render these partial views.

In the commonview action, we pass in a model to prepare for passing parameters later.

Next, I wrote this view:

The action to render part of the view is created.It also doesn't have much html code.

Let's create 2 partial views,Of course, in the actual environment,Maybe more than two.

Partial view_view1:

Partial view 2:

Everything is ready beforeAll are for the following ng-include demonstration:

Program running results:

to sum up

  • Previous Laravel implements form submission
  • Next Vue model vue advanced tutorial