Krishna Prasad Ambaripeta Krishna Prasad Ambaripeta - 5 months ago 11
AngularJS Question

Calling template inside template angularjs

Tracking and nutrition templates are called like below:

.state('app.tracking', {
url: '/tracking',
views: {
'menuContent': {
templateUrl: 'templates/tracking.html',
controller: 'TrackingCtrl'
}
}
})

.state('app.nutrition', {
url: '/nutrition',
views: {
'menuContent': {
templateUrl: 'templates/nutrition.html',
controller: 'NutritionCtrl'
}
}
})


When tracking route is called tracking.html will be displayed.
I also want to display the nutrition.html inside the tracking.html when called.

So, in tracking.html I have included code like below:

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


expecting that nutrition.html is also displayed inside tracking.html when my route is tracking.html.
But not working. Anything missing here?

Answer

Try wrapping your URL in single quotes. <ng-include src=" 'templates/nutrition.html' "></ng-include>