Answer the question
In order to leave comments, you need to log in
How to use multiple templates with defined template hierarchy in angularjs?
Hello. I'm new to angularjs development, so I'm asking for help from developers with experience.
Angular has a great $routeProvider service that binds our html templates.
There is also a $stateProvider service that also binds and can break apart our templates.
The question is which service to use and how to use them correctly so that the interaction of templates is performed, well, if, for example, according to this principle:
index - view
->header.html
->content.html
->leftBlock.html -> login.html
->footer .html
i.e. To make it easier to understand what is needed, I need all these templates to be linked in index.html, and when you click on the login, a modal window is loaded that will load another template.
Please show an example of a working code where one template loads another.
var mainApp = angular.module('mainApp', [
'ngRoute',
'mainControllers'
]);
mainApp.config(['$routeProvider',
function ($routeProvider) {
$routeProvider.
when('/main', {
templateUrl: '../resources/templates/mainContent.html',
controller: 'mainContentCtrl'
}).
when('/main/:itemId', {
templateUrl: '../resources/templates/mainDetails.html',
controller: 'mainDetailCtrl'
}.
otherwise({
redirectTo: '/main'
});
}]);
Answer the question
In order to leave comments, you need to log in
Perhaps you need to make sure that login.html is simply wrapped in a div that is displayed modally?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question