繁体   English   中英

angular routeprovider 包括页眉、页脚和模板

[英]angular routeprovider include header, footer and template

我正在尝试向链接添加模板,这是有效的,但是我想知道是否有可能将您的页眉和页脚添加到它,现在我正在为每个页面复制我的页眉和页脚。

这是我的js:

  app.config(['$routeProvider', '$locationProvider',
        function($routeProvider, $locationProvider) {
            $routeProvider
                .when('/', {
                    templateUrl: 'views/startpage.html',
                    controller: 'PageCtrl',
                    controllerAs: 'page'
                })
                .when('/page/test', {
                    templateUrl: 'test.html',
                    controller: 'PageCtrl',
                    controllerAs: 'page'
                })

这是我加载它们的模板

<html>
<head>
    <meta charset="utf-8" />
    <link rel="stylesheet" type="text/css" href="css/bootstrap.css" />
    <link rel="stylesheet" type="text/css" href="css/index.css" />
    <script src="js/angular.min.js"></script>
    <script src="js/angular-route.js"></script>
    <script src="js/angular-animate.js"></script>
    <script type="text/javascript" src="js/app.js"></script>

    <script type="text/javascript">
        angular.element(document.getElementsByTagName('head')).append(angular.element('<base href="' + window.location.pathname + '" />'));
    </script>

    <title>SiteEngine Mobile</title>
</head>
<body ng-app="ngViewExample">
    <div class="fixedHeaderApp">
        <div class="headerIconLogo">
            <img src="img/world_icon.png" width="28px" height="28px" />
        </div>
        <span class="blue">Site</span><span class="orange">Engine</span>
    </div>

    <div class="whitespace"></div><div class="whitespace"></div>
    <div class="whitespace"></div><div class="whitespace"></div>
    <div class="whitespace"></div><div class="whitespace"></div>

    <div class="homebackimgWrapper">
        <div class="titleLarge">SiteEngine</div>
        <div class="titleSmall">Mobile</div>
    </div>
    <div class="container">
        <div class="loginLogo">
            <img src="img/loginIcon.png" width="120px" height="120px" />
        </div>

        <form action="views/startpage.html">
            <div class="form-group">
                <input type="email" class="form-control" id="exampleInputEmail1" placeholder="Email">
            </div>
            <div class="form-group">
                <input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
            </div>
            <div class="checkbox">
                <label>
                    <input type="checkbox"> Ingelogd blijven
                </label>
            </div>
            <button type="submit" class="btn btn-primary btnq-lg btn-block">Inloggen</button>
        </form>

        <div class="whitespace"></div>

        <div ng-controller="HomeController as product">
            <div ng-repeat="product in product.products">
                <h4>{{product.name}}</h4>
                <button ng-show="product.canPurchase">Add to stomach</button>
            </div>
        </div>
    </div>


    <script type="text/javascript" src="js/index.js"></script>
    <script type="text/javascript">
        app.initialize();
    </script>
</body>

我也有不同的页面,有不同的菜单选项。

您可以尝试使用 ng-view 作为包含您的模板的地方。 您的页脚和页眉将在该 ng-view 之外。 您还可以直接在 html 中呈现您的菜单。 只需将您的菜单和链接的地图放在某处并将其呈现在 html 中。

暂无
暂无

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

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