Angular ui-router:链接不可点击

时间:2022-04-16 19:39:07

I try to run angular-ui-router to handle my views but i have a problem. The two links of the following view are not clickable. Angular change variable with link label but i can't click on.

我尝试运行angular-ui-router来处理我的观点,但我遇到了问题。以下视图的两个链接不可单击。带链接标签的角度变化变量,但我无法点击。

I have this view :

我有这个观点:

<!DOCTYPE html>
<html ng-app="MyApp">
    <head>
            <meta charset="utf-8">
    </head>
    <body>
        <h1>App</h1>
        <nav>
            <a ui-shref="app">{{link.home}}</a>
            <a ui-shref="app.front.signin">{{link.signin}}</a>
        </nav>
         <div ui-view="content">
        </div>
    </body>
</html>    

I use this code. It do not returns errors . All modules (localStorage ... are included) but links are not clickable.

我用这个代码。它不会返回错误。所有模块(包括localStorage ...)但链接不可点击。

/**
 * Declaration of MyAppControllers module
 */
 MyAppControllers = angular.module('MyAppControllers',[]);
/**
 * Declaration of MyApp Application
 */
MyApp = angular.module('MyApp', ['MyAppControllers','LocalStorageModule','ui.router']);  


MyApp.config(['$stateProvider', '$urlRouterProvider',
function ($stateProvider, $urlRouterProvider) {
    $urlRouterProvider.otherwise("/");
    //
    // Now set up the states
    $stateProvider
            .state('app', {
                url: "/",
                views: {
                    "content": {templateUrl: "views/front/home-1.0.html"}
                }
            }) 
            .state('app.front.signin', {
                url: "/signin",
                views: {
                    "content": {templateUrl: "views/front/home-1.0.html", controller: "signinCtrl"}
                }
            });

    }
]);

Can someone help me ?

有人能帮我吗 ?

1 个解决方案

#1


5  

You messed up in type it should be ui-sref instead of ui-shref

你搞砸了它应该是ui-sref而不是ui-shref

<body>
    <h1>App</h1>
    <nav>
        <a ui-sref="app">{{link.home}}</a>
        <a ui-sref="app.front.signin">{{link.signin}}</a>
    </nav>
     <div ui-view="content">
    </div>
</body>

Your second link should be app.signin instead of app.front.signin because you don't have parent route front

您的第二个链接应该是app.signin而不是app.front.signin,因为您没有父路由前端

.state('app.signin', {
    url: "/signin",
    views: {
        "content": {
            templateUrl: "views/front/home-1.0.html", 
            controller: "signinCtrl"
        }
    }
});

#1


5  

You messed up in type it should be ui-sref instead of ui-shref

你搞砸了它应该是ui-sref而不是ui-shref

<body>
    <h1>App</h1>
    <nav>
        <a ui-sref="app">{{link.home}}</a>
        <a ui-sref="app.front.signin">{{link.signin}}</a>
    </nav>
     <div ui-view="content">
    </div>
</body>

Your second link should be app.signin instead of app.front.signin because you don't have parent route front

您的第二个链接应该是app.signin而不是app.front.signin,因为您没有父路由前端

.state('app.signin', {
    url: "/signin",
    views: {
        "content": {
            templateUrl: "views/front/home-1.0.html", 
            controller: "signinCtrl"
        }
    }
});