D
D
Dima nahkar2015-08-12 14:06:57
JavaScript
Dima nahkar, 2015-08-12 14:06:57

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

1 answer(s)
S
Sergey, 2015-08-12
@nahkar

$rootScope.$on(
    '$stateChangeError',
    function (event, toState, toParams, fromState, fromParams, error) {
      if (!angular.isString(error)) {
        error = JSON.stringify(error);
      }
      $log.error('$stateChangeError: ' + error);
    }
  );

have a nice debug, and fix the typo with the template in contacts.list

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question