Google Maps的AngularJS路由

伊恩·彭纳贝克

我无法让第二个视图显示在我的应用中。该应用程序应该做的是列出位置,当您单击某个位置时,它应该被路由到嵌入了Google Map的其他视图并在该位置搜索坐标。我已经为我的项目设置了一个插件 for我相信我的问题出在定义我的控制器/模块上。我会将代码发布在这里,但是有多个类可能会引起混淆。有人可以帮忙吗?

演示:http//plnkr.co/edit/OZZRgiEcrLzreW3lrc5v?p = preview

诺贝尔奖

这应该可以进一步帮助您:http : //plnkr.co/edit/IEj0HAolgmUVrCghMtgN

除其他外,您的路由配置不正确

    $routeProvider
      .when("/index", {
        templateUrl:"index.html", 
        controller: "firstCtrl"})
      .when("/map", {
        templateurl:"map.html",
        controller: "MapController"})
      .otherwise("/index");

这会将您的默认视图(包含在中)<div ng-view>设置为index.html,其中包含<div ng-view>像无限循环之类的东西。

我将视图分为两个:search.html和map.html,并将路由更新为如下所示:

$routeProvider
      .when("/search", {
        templateUrl: "search.html",
        controller: "searchController"
      })
      .when("/map/:locationName", {
        templateUrl: "map.html",
        controller: "mapController"
      })
      .otherwise({
        redirectTo: '/search'
      });

另外,您的地图数据也没有发送到mapController。有关解决方案,请参见plunkr。您现在唯一需要做的就是发送位置而不是名称。

我已经整理了一下代码,并提供了一些有关路由工作方式以及如何改进模块定义的信息。

当我开始使用AngularJS时,这对我非常有帮助。它也可能对您有帮助:https : //docs.angularjs.org/tutorial/

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Google Maps的AngularJS路由

来自分类Dev

防止Google索引AngularJS路由

来自分类Dev

从Google Maps API路由导航信息

来自分类Dev

Google Maps Markers和AngularJS

来自分类Dev

无法使AngularJS Google Map居中/ AngularJS Google Maps API的使用

来自分类Dev

Google Maps无法使用angularjs加载

来自分类Dev

AngularJS中Google Maps的路线标记

来自分类Dev

使用AngularJS在Google Maps中实现标记

来自分类Dev

AngularJS + Google Maps不显示标记

来自分类Dev

AngularJs-Google-Maps标记未显示

来自分类Dev

angularjs-google-maps 信息窗口位置

来自分类Dev

使用 AngularJS 动态加载 Google Maps API

来自分类Dev

定义应用正在使用Google Maps iOS SDK路由应用

来自分类Dev

iOS Google Maps API路由无法正确显示

来自分类Dev

在Google Maps SDK中查找要路由的位置的距离

来自分类Dev

如何使用angularjs和Google Maps更改图标标记

来自分类Dev

模型未在Google Maps侦听器中更新-angularjs

来自分类Dev

Trying to get simple Google Maps example to work with AngularJS

来自分类Dev

(angularjs-google-maps)ng在标记内单击

来自分类Dev

带有Google Maps指令的AngularJS测试控制器

来自分类Dev

如何使用angularjs和Google Maps更改图标标记

来自分类Dev

将Google Maps API添加到AngularJS

来自分类Dev

AngularJs和Google Maps问题:不显示标记?

来自分类Dev

添加标记时的离子angularjs-google-maps TypeError

来自分类Dev

AngularJS 如何从 Google Maps 脚本预填充的 <textarea> 获取数据

来自分类Dev

Google Maps Javascript API v3路由迭代

来自分类Dev

iOS与Google Maps

来自分类Dev

Android Google Maps LocationClient

来自分类Dev

google maps with ionic