首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AngularJS和Laravel 4:开发人员的预测(纬度和经度)

AngularJS和Laravel 4:开发人员的预测(纬度和经度)
EN

Stack Overflow用户
提问于 2014-08-19 15:47:45
回答 1查看 376关注 0票数 2

从我的桌子,节日,地址,我正在制作JSON的位置:

代码语言:javascript
复制
$festival = Festival::with('address.location')->get();

return Response::json(array('festivals' => $festival))->setCallback(Input::get('callback'));

我使用angularJS加载JSON,当我在视图中输入以下内容时:

代码语言:javascript
复制
<div ng-repeat="festival in festivals">
    <p>{{festival.address.location.location_latitude}}</p>
    <p>{{festival.address.location.location_longitude}}</p>
</div>

我知道纬度和经度。

我使用的是来自sotospez的天气预报指令:

https://github.com/sotospez/angular-weather-forecast

例如,我可以在天气视图中输入:

代码语言:javascript
复制
<weather location="36.453153,28.2092523" color="#f2f2f2" apikey="yourapikey"></weather>

我现在的问题是,如何在这个位置属性中获得我的json的纬度和经度?

这不管用:

代码语言:javascript
复制
location="{{festival.address.location.location_latitude}},{{festival.address.lo‌​cation.location_longitude}}

更新

我在控制台中看到了这个错误:

代码语言:javascript
复制
Error: [$parse:lexerr] Lexer Error: Unexpected next character  at columns 19-19 [‌] in expression [festival.address.lo‌​cation.location_longitude].

longitude

{{festival.address.lo‌​cation.location_longitude}}出了点问题

现在我得到了错误:

代码语言:javascript
复制
GET https://api.forecast.io/forecast/182c80b516693d7731697710f7e1a807/%7Bfestival.address.location.location_latitude%7D%7D,?callback=angular.callbacks._5 400 (Bad Request) 
EN

回答 1

Stack Overflow用户

发布于 2014-08-19 23:39:02

这个指令是读取链接函数中的location属性,您可以在这里看到https://github.com/sotospez/angular-weather-forecast/blob/master/js/weather.js#L108,这意味着它只读取一次值,而且如果数据不可用,那么您完全不走运,因为它已经在没有数据的情况下发出了http请求。

在数据准备好之后,您需要将该元素添加到DOM中,我猜您在某个地方发出ajax请求来加载数据,因此在那个时候追加那个天气元素

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25387755

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档