OpenStreetMap的角度以$ routeProvider [英] Angular OpenStreetMap with $routeProvider

查看:133
本文介绍了OpenStreetMap的角度以$ routeProvider的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是单页的应用程序。
有什么,我需要
<一href=\"https://github.com/tombatossals/angular-leaflet-directive/blob/master/examples/simple-example.html\" rel=\"nofollow\">https://github.com/tombatossals/angular-leaflet-directive/blob/master/examples/simple-example.html

Here is the single page app. There is what I need https://github.com/tombatossals/angular-leaflet-directive/blob/master/examples/simple-example.html

但我想添加菜单...

but I want add menu...

<html ng-app="App">
<head>
<link rel="stylesheet" href="//.../bootstrap.min.css" />
<link rel="stylesheet" href="//.../bootstrap.css" />
<link rel="stylesheet" href="//.../font-awesome.css" />
<script src="http://.../leaflet.js"></script>
<script src="http://...1.2.6/angular.min.js"></script>
<script src="angular-leaflet-directive.min.js"></script>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.1/leaflet.css">
    <script>
    var App = angular.module('App', ['leaflet-directive']);

    App.config(function ($routeProvider, $locationProvider) {
        $locationProvider.html5Mode(true);
        $routeProvider

            .when('/', {
                templateUrl: 'pages/home.html',
                controller: function ($scope) {
                }
            })

            .when('/about', {
                templateUrl: 'pages/about.html',
                controller: function ($scope) {
                }
            });
    });

</script>

Home.html然后在about.html包括

home.html and about.html consist of

</head>
<body >
<nav class="navbar navbar-default navbar-static-top">
        <ul class="nav navbar-nav">
            <li><a href="/"> home</a></li>
            <li><a href="/about"> about</a></li>
        </ul>
</nav>

    <div ng-view></div>
</body>
</html>

谢谢!

推荐答案

路由工作,你需要确保你注射ngRoute:

for routing to work you need to be sure you are injecting ngRoute:

<script type="text/javascript" src="angular-route.min.js"></script>

var App = angular.module('App', ['leaflet-directive', 'ngRoute']);

我会建议得到路由的工作,你开始添加其他指令之前。

I would recommend getting routing working before you start adding other directives.

这篇关于OpenStreetMap的角度以$ routeProvider的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆