user3044394
user3044394

Reputation: 135

scope variable not working with ng-include src

So first of all, this works: (The html loads)

<div ng-include src="'start.html'"></div>

Here, the sideBar variable shows that the sideBar scope variable is equal to 'start.html' but when I insert it into the ng-include src - it does not work.

<div>{{ sideBar }}</div> <!-- sideBar appears on the page as start.html -->
<div ng-include src="'{{ sideBar }}'"></div> 

This also does not work:

<div ng-include src="{{ sideBar }}"></div>

and this does not work either:

<div ng-include src={{ sideBar }}></div>

only this works:

<div ng-include src="'start.html'"></div>

How can I make the include work with a scope variable?

Upvotes: 0

Views: 1091

Answers (2)

Stepan Kasyanenko
Stepan Kasyanenko

Reputation: 3186

Read documentation for ng-include.

Following works:

<div ng-include="sideBar"></div>

Upvotes: 3

user3044394
user3044394

Reputation: 135

<div ng-model="sideBar" ng-include src="sideBar"></div>

this works

Upvotes: 0

Related Questions