如何使用AngularJs ui-route

时间:2017-04-04 17:47:10

标签: angularjs

我正在尝试处理找不到Angular ui-router的页面和"否则"。

当我点击标记的锚链接时,我有下一个错误:

Error: Could not resolve '/erro' from state 'errorpage'
    at Object.transitionTo (angular-ui-router.js:3248)
    at Object.go (angular-ui-router.js:3176)
    at angular-ui-router.js:4267
    at angular.js:19916
    at completeOutstandingRequest (angular.js:6111)
    at angular.js:6390

这是我的代码:

标记:

 <li><a ui-sref='/erro'>DashBoard</a></li>
 <li><a ui-sref='/erro'>Caixa</a></li>

angular app.js:

    app.config(function($stateProvider, $urlRouterProvider,$locationProvider) {
      $urlRouterProvider.otherwise(function ($injector, $location) {
            var $state = $injector.get('$state');

            $state.go('errorpage', {
                title: "Page not found",
                message: 'Could not find a state associated with url "'+$location.$$url+'"'
            });
        });
      $stateProvider
        .state('errorpage',{
          url: "*path",
          template:'<div>{{title}}-{{message}}</div>'
        })  

.........

continues

0 个答案:

没有答案