Answer the question
In order to leave comments, you need to log in
Angular ui.router doesn't fire controller: '' and templateUrl: ''?
Hello!
I just started learning angularjs, I
ran into the problem of building a url for localization,
for example:
/ru/
/en/
/en/about/
/en/contacts/
Worth
angularjs 1.4.8
ngRouter 1.4.8
ui-router 0.2.15
The router itself
module.exports = App.Angular
.config(['$stateProvider', '$urlRouterProvider', '$locationProvider',
function($stateProvider, $urlRouterProvider, $locationProvider) {
$locationProvider.html5Mode(true);
$urlRouterProvider.otherwise('/' + App.Lang + '/');
$stateProvider
.state('root', {
url: '/{lang:ru|en|de}',
abstract: true,
})
.state('root.home', {
url: '/',
templateUrl: '/frontend/app/template/index.php',
controller: 'MainController',
})
.state('root.home.about', {
url: 'about/',
templateUrl: '/frontend/app/template/about.php',
controller: 'AboutController'
});
}
]);
.state('home', {
url: '/{lang:ru|en|de}/',
templateUrl: '/frontend/app/template/index.php',
controller: 'MainController',
})
.state('home.about', {
url: 'about/',
templateUrl: '/frontend/app/template/about.php',
controller: 'AboutController'
});
Answer the question
In order to leave comments, you need to log in
Found a solution, added template: '' and specified the template with the controller through views
$stateProvider
.state('root', {
url: '/{lang:ru|en|de}',
abstract: true,
template: '<div ui-view></div>'
})
.state('root.home', {
url: '/',
views: {
'': {
templateUrl: '/frontend/app/template/index.php',
controller: 'MainController'
}
}
})
.state('root.about', {
url: '/about/',
views: {
'': {
templateUrl: '/frontend/app/template/about.php',
controller: 'AboutController'
}
}
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question