Angular ui-router:链接不可点击 [英] Angular ui-router : Links are not clickable

查看:25
本文介绍了Angular ui-router:链接不可点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

我有这个观点:

<html ng-app="MyApp"><头><meta charset="utf-8"><身体><h1>应用</h1><导航><a ui-shref="app">{{link.home}}</a><a ui-shref="app.front.signin">{{link.signin}}</a></nav><div ui-view="内容">

</html>

我使用此代码.它不返回错误.所有模块(localStorage ...都包括在内)但链接不可点击.

/*** MyAppControllers 模块的声明*/MyAppControllers = angular.module('MyAppControllers',[]);/*** MyApp 应用程序声明*/MyApp = angular.module('MyApp', ['MyAppControllers','LocalStorageModule','ui.router']);MyApp.config(['$stateProvider', '$urlRouterProvider',函数($stateProvider,$urlRouterProvider){$urlRouterProvider.otherwise("/");////现在设置状态$stateProvider.state('应用程序', {网址:/",意见:{内容":{templateUrl:views/front/home-1.0.html"}}}).state('app.front.signin', {网址:/登录",意见:{内容":{templateUrl:views/front/home-1.0.html",控制器:signinCtrl"}}});}]);

有人可以帮我吗?

解决方案

你把类型搞砸了,它应该是 ui-sref 而不是 ui-shref

<h1>应用</h1><导航><a ui-sref="app">{{link.home}}</a><a ui-sref="app.front.signin">{{link.signin}}</a></nav><div ui-view="内容">

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

.state('app.signin', {网址:/登录",意见:{内容": {templateUrl: "views/front/home-1.0.html",控制器:signinCtrl"}}});

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.

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.

/**
 * 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 ?

解决方案

You messed up in type it should be ui-sref instead of 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

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

这篇关于Angular ui-router:链接不可点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
前端开发最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆