从我的桌子,节日,地址,我正在制作JSON的位置:
$festival = Festival::with('address.location')->get();
return Response::json(array('festivals' => $festival))->setCallback(Input::get('callback'));我使用angularJS加载JSON,当我在视图中输入以下内容时:
<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
例如,我可以在天气视图中输入:
<weather location="36.453153,28.2092523" color="#f2f2f2" apikey="yourapikey"></weather>我现在的问题是,如何在这个位置属性中获得我的json的纬度和经度?
这不管用:
location="{{festival.address.location.location_latitude}},{{festival.address.location.location_longitude}}更新
我在控制台中看到了这个错误:
Error: [$parse:lexerr] Lexer Error: Unexpected next character at columns 19-19 [] in expression [festival.address.location.location_longitude].longitude
{{festival.address.location.location_longitude}}出了点问题
现在我得到了错误:
GET https://api.forecast.io/forecast/182c80b516693d7731697710f7e1a807/%7Bfestival.address.location.location_latitude%7D%7D,?callback=angular.callbacks._5 400 (Bad Request) 发布于 2014-08-19 23:39:02
这个指令是读取链接函数中的location属性,您可以在这里看到https://github.com/sotospez/angular-weather-forecast/blob/master/js/weather.js#L108,这意味着它只读取一次值,而且如果数据不可用,那么您完全不走运,因为它已经在没有数据的情况下发出了http请求。
在数据准备好之后,您需要将该元素添加到DOM中,我猜您在某个地方发出ajax请求来加载数据,因此在那个时候追加那个天气元素
https://stackoverflow.com/questions/25387755
复制相似问题