I am having trouble with my Angular JS ui-router and every question I have found on here shows a solutions I have already tried.
In my ui-view-tag my actual template is not displayed.
<body ng-app="myApp">
<div class="row">
<div class="col-md-6 col-md-offset-2">
<ui-view></ui-view>
</div>
</div>
</body>
This is my app.js
angular.module('myApp', ['ui.router'])
.config(['$stateProvider', '$urlRouterProvider',
function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('home', {
url: '/',
templateUrl: 'home.html',
controller: 'MainCtrl'
})
$urlRouterProvider.otherwise('home');
}])
Thank you very much everybody, I would really appreciate a short feedback on that.
The $urlRouterProvider
otherwise()
accepts the url path you want to redirect to. Therefore, you need to change:
$urlRouterProvider.otherwise('home');
To:
$urlRouterProvider.otherwise('/');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.