Answer the question
In order to leave comments, you need to log in
What is the correct way to implement loop in javascript?
Hello!
Please tell me how you can run through the object using loop, get the necessary information and add data to another part of the code.
var App = angular.module('App', ['ngRoute']);
var partialDir = '/partials/';
var pageFormat = '.html';
var pages = {
'home': {
'url': '/',
'partialName': 'index',
'link': partialDir + this.partialName + pageFormat,
'controllerName': this.partialName + 'Controller',
'pageTitle': 'Welcome home'
},
'page': {
'url': '/page',
'partialName': 'page',
'link': partialDir + this.partialName + pageFormat,
'controllerName': this.partialName + 'Controller',
'pageTitle': 'Page'
},
'page2': {
'url': '/page2',
'partialName': 'page2',
'link': partialDir + this.partialName + pageFormat,
'controllerName': this.partialName + 'Controller',
'pageTitle': 'Page2'
}
};
App.config(function($routeProvider,$locationProvider){
$routeProvider
.when('/',{
templateUrl: '/partials/index.html'
})
.when('/page', {
templateUrl: '/partials/page.html'
})
.when('/page2', {
templateUrl: '/partials/page2.html'
})
.when('/admin', {
templateUrl: '/partials/admin.html'
})
.otherwise({
redirectTo: '/'
});
$locationProvider.html5Mode({
enabled: true,
requireBase: false
});
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question