Issue
My routes
file looks like:
.state('dashboard', {
url: '/dashboard'
views:
appView:
templateUrl: '/templates/main.html'
dashboardView:
templateUrl: '/templates/partialDashboard.html'
}).
main.html
looks like:
<section class='main-page container'>
<div class="row">
<div class="col-md-3 lnHeaderArea">
<ng-include src="'/templates/companyHeader.html'"></ng-include>
</div>
<div id="main-area" class="col-md-9">
<div ui-view="dashboardView"></div>
<ng-include src="'/templates/dashboardFooter.html'"></ng-include>
</div>
</div>
</section>
and partialDashboard.html
looks like:
<section ng-controller="DashboardController">
<ng-include src="'/templates/dashboardInstitutionalDemand.html'"></ng-include>
<ng-include src="'/templates/dashboardPriceVolume.html'"></ng-include>
<ng-include src="'/templates/dashboardBlockExecutions.html'"></ng-include>
<ng-include src="'/templates/dashboardAnalytics.html'"></ng-include>
</section>
But for some reason, those ng-include
'd templates won't load. Any reason why?
Solution
ng-includes work fine inside the templateUrl.
Try this Plnkr or Plnkr with state: views which demonstrates just that
Explanation is below
Route using templateUrl
This is in the route1 which has templateUrl: route1.html
$stateProvider
.state('route1', {
url: "/route1",
templateUrl: "route1.html"
})
.state('route1.list', {
url: "/list",
templateUrl: "route1.list.html",
controller: function($scope) {
$scope.items = ["A", "List", "Of", "Items"];
}
})
or as per the state view like what you have
.state('main', {
url: '/main',
views: {
'route1': {
templateUrl: "route1.html"
},
'route2': {
templateUrl: "route2.html"
},
}
})
The template that has ng-include in it -route1.html Notice myNgIncludeSample.html
<h1>Route 1</h1>
<hr/>
<div ng-include="'myNgIncludeSample.html'">
</div>
<hr/>
<a href="#/route1/list">Show List</a>
<div ui-view></div>
I see that your .state('dashboard') looks different. You may want to fix your as below. Add those curly {} braces. UPDATED: The coffeescript syntax seems fine however my following pure JS code is working without any problem.
.state('dashboard', {
url: '/dashboard'
views: {
'appView': {
templateUrl: '/templates/main.html'
},
'dashboardView': {
templateUrl: '/templates/partialDashboard.html'
}
}).
Answered By - bhantol
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.