单页应用跳转ui-view,$stateProvider,$urlRouterProvider

Posted 柒夏°

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了单页应用跳转ui-view,$stateProvider,$urlRouterProvider相关的知识,希望对你有一定的参考价值。

<!DOCTYPE html>
<html ng-app="myApp">

    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1,user-scalable=no">
        <title>angular animation-ngView例子</title>
        <link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0-wip/css/bootstrap.min.css">
        <style type="text/css">
            .container {
                -webkit-perspective: 500;
                -moz-perspective: 500;
                -ms-perspective: 500;
                perspective: 500;
                position: relative;
            }
            
            .slide.ng-leave {
                position: relative;
            }
            
            .slide.ng-enter {
                position: absolute;
            }
            
            .slide.ng-enter,
            .slide.ng-leave {
                -webkit-transition: -webkit-transform 0.3s ease-in, opacity 0.3s ease-in;
                -moz-transition: -moz-transform 0.3s ease-in, opacity 0.3s ease-in;
                -o-transition: -o-transform 0.3s ease-in, opacity 0.3s ease-in;
                transition: transform 0.3s ease-in, opacity 0.3s ease-in;
            }
            
            .slide.ng-enter,
            .slide.ng-leave.ng-leave-active {
                -webkit-transform: scaleX(0.0001);
                -o-transform: scaleX(0.0001);
                transform: scaleX(0.0001);
                opacity: 0;
            }
            
            .slide,
            .slide.ng-enter.ng-enter-active {
                -webkit-transform: scaleX(1);
                -o-transform: scaleX(1);
                transform: scaleX(1);
                opacity: 1;
            }
        </style>
        <script type="text/javascript" src="http://apps.bdimg.com/libs/angular.js/1.2.16/angular.min.js"></script>
        <script type="text/javascript" src="http://apps.bdimg.com/libs/angular.js/1.3.0-beta.8/angular-animate.min.js"></script>
        <script type="text/javascript" src="http://cdn.staticfile.org/angular-ui-router/0.2.11/angular-ui-router.min.js"></script>
    </head>

    <body>
        <header role="banner" id="top" class="navbar navbar-static-top navbar-inverse">
            <div class="container">
                <nav role="navigation" class="collapse navbar-collapse ">
                    <ul class="nav navbar-nav">
                        <li ui-sref-active="active">
                            <a href ui-sref="home">Home</a>
                        </li>
                        <li ui-sref-active="active">
                            <a href ui-sref="about">About</a>
                        </li>
                        <li ui-sref-active="active">
                            <a href ui-sref="contacts">Contacts</a>
                        </li>
                    </ul>
                </nav>
            </div>
        </header>
        <!--//-->
        <div class="container">
            <div class="slide" ui-view></div>
        </div>
        <!--//-->
        <script type="text/javascript">
            var myApp = angular.module("myApp", ["ui.router", "ngAnimate"]);
            myApp.config([$stateProvider, $urlRouterProvider,
                function($stateProvider, $urlRouterProvider) {
                    $stateProvider.state("home", {
                        url: "/home",
                        template: "<h1>三十年功尘与土</h1>"
                    }).state("about", {
                        url: "/about",
                        template: "<h1>八千里路云和月</h1>"
                    }).state("contacts", {
                        url: "/contacts",
                        template: "<h1>莫等闲,白了少年头,空悲切</h1>"
                    });
                    $urlRouterProvider.otherwise("/home");
                }
            ]);
        </script>
    </body>

</html>

 

以上是关于单页应用跳转ui-view,$stateProvider,$urlRouterProvider的主要内容,如果未能解决你的问题,请参考以下文章

vue 单页应用点击某个链接,跳转到新页面的方式

原创Ionic单页应用跳转外链,构造路由返回的解决办法及代码

单页应用和多页应用

浅谈单页应用和多页应用——Vue.js向

base.html 中的 js 未应用于 ui-view 中加载的 angular/materializecss 模板

前端词典单页应用 VS 多页应用