Ng-include src binding using $ scope property

In angularjs app I want to load partial view dynamically, so I mean

<ng-include src="'{{ pathView }}'"></ng-include>

      

this view is of course associated with a specific controller, and in my controller i have

 $scope.pathView= "/templates/listView.html";

      

it doesn't work as when examining the html view I get

<!-- ngInclude: undefined -->

      

When I hardcode the path to the template

<ng-include src="'/templates/listView.html'"></ng-include>

      

it works.

What am I doing wrong?

+3


source to share


2 answers


src

in ng-include

angular expression is required reference so you can bind it to model value below



<ng-include src="pathView"></ng-include>

      

+2


source


Delete {{

and}}



The right way <ng-include src="pathView"></ng-include>

+2


source







All Articles