Different ng-include's on the same page: how to send different variables to each?

前端 未结 15 1336
北海茫月
北海茫月 2020-12-04 12:17

I\'ve got a page in my AngularJS app in which I would like to include the same html partial, but with different variables. If I do this in my main html:

15条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-04 13:02

    In your comment on @jm-'s answer, you mention you want to load your partial inside ng-repeat. To do this, create an array on your $scope, and set the unique values on that array:

    $scope.partialStuff = [ 'p1', 'p2', 'p3' ];
    

    Somewhere in your partial:

    {{partialVar}}
    

    The HTML:

    Fiddle.

提交回复
热议问题