Answer the question
In order to leave comments, you need to log in
Why doesn't UI - ROUTER work in Angular?
I don’t understand why I don’t see the view when I follow the link, and there are no errors in the console.
<body ng-app="app">
<div ng-controller="Ctrl">
<a ui-sref="contacts.list">list</a>
<a ui-sref="contacts.detail">detail</a>
<div ui-view></div>
</div>
<script>
angular.module("app", ['ui.router'])
.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('contacts', {
abstract: true,
url: '/contacts',
template: '<ui-view/>'
})
.state('contacts.list', {
url: '/list',
tepmlate: "111111"
})
.state('contacts.detail', {
url: '/detail',
tepmlate: "22222"
})
$urlRouterProvider.otherwise("/");
})
.controller("Ctrl", function($scope){
$scope.name = "aaa";
})
</script>
</body>
Answer the question
In order to leave comments, you need to log in
$rootScope.$on(
'$stateChangeError',
function (event, toState, toParams, fromState, fromParams, error) {
if (!angular.isString(error)) {
error = JSON.stringify(error);
}
$log.error('$stateChangeError: ' + error);
}
);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question