Laravel /角:PHP页面内将数据传递到angularjs [英] Laravel/Angular: passing data within php page to angularjs

查看:167
本文介绍了Laravel /角:PHP页面内将数据传递到angularjs的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下laravel HTML /刀片页,我想通过一个 STOREID 的话可以通过角得到拾起,然后用得到,并做一些运作与

I have the following laravel html/blade page and i want to pass in a storeid that then can get picked up via angular to then use to get and do some workings with.

下面就是我现在如何完成,但有一个更好的方式来产生相同的?

Below is how i am accomplishing it NOW but is there a better way to produce the same?

刀片部分

<div ng-controller="storeChartCtrl" data-storeid="{{ $store['id'] }}">
    <p>{{ $store['name'] }} Sales</p>
    ...
</div>

角按Ctrl

.controller('storeChartCtrl', ['$scope', 'Store', function($scope, Store){
    //-- get the requested store sales
    var storeid = JQ('#storeChart').data('storeid');

    $log.info(storeid);
    ....

这个当前工作,​​我让我的STOREID的价值,所以我就可以发送到我厂来获得数据。

This currently works and i get my storeid value so i can then send to my factory to get the data.

推荐答案

在使用角(甚至只是jQuery的),我感谢 @ JeffreyWay 此软件包:

When using Angular (or even just jQuery), I thank @JeffreyWay for this package:

https://github.com/laracasts/PHP-Vars-To- JS-变压器

这篇关于Laravel /角:PHP页面内将数据传递到angularjs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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