Search code examples
angularjsasp.net-mvcangularjs-ng-include

how to dynamically add page using ng-include with asp.net MVC using angular js


Here i am trying to call partial view from controller using angular js.

here is my code

<div ng-repeat='t in tabs'>
<div ng-include='t.templateUrl'></div>
<div>

when i try to include like ng-include="'/home/menutemplate'" it will includes the content. How can i dynamically do this? . Help me


Solution

  • t.templateUrl should be valid scope variable and should hold a string(path for the template):

    $scope.t.templateUrl = "/home/menutemplate"
    

    And in your template:

    <div ng-include="t.templateUrl"></div>