简体   繁体   English

无法解决ui-route中的状态错误

[英]Cannot resolve state error in ui-route

I have this in route.js 我在route.js中有这个

.state('app', {
        url:'/app',
        templateUrl: 'partials/dashboard/index.html'
      })

      .state('app.sales', {
        url:'/app/sales',
        templateUrl: 'partials/dashboard/sales.html'
      })

Then this is my view 那是我的看法

<div class="container" ng-controller="DashboardCtrl as vm" ng-init="vm.init()">
    <aside>
        <ul>
            <li ui-sref="sales">Sales</li>
        </ul>
    </aside>
    <div ui-view></div>
</div>

When I clicked on the li, in my console I saw this error Could not resolve 'sales' from state 'app' 当我单击li时,在控制台上我看到此错误Could not resolve 'sales' from state 'app'

What's wrong? 怎么了? I'm trying to use nested view. 我正在尝试使用嵌套视图。 I want my sidebar to remain and the content change dynamically. 我希望我的侧边栏保持不变,并且内容可以动态更改。

在ui-sref中使用'app.sales'状态名称代替

You want to go to the app.sales when putting up a ui-sref on anchor tags. 在锚点标签上放置ui-sref时,您想转到app.sales So, you'd do it like this : 因此,您可以这样做:

 <li><a ui-sref="app.sales">Sales</a></li> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM