我在URL中传递ID时不显示角度数据

时间:2016-11-16 05:53:41

标签: jquery angularjs laravel laravel-5 laravel-5.2

我正在使用角度js在laravel 5.3上工作。我在Angular数据显示中遇到的问题是我在URL中传递ID。

我的网址

 http://localhost/demohotel/public/home/1359982

My Angular脚本代码

<script>
var GroupsApp = angular.module('GroupsApp',[]);

GroupsApp.controller('GroupsController', function ($scope, GroupsService) 
{
    getGroups();
    function getGroups() {
        GroupsService.getGroups()
            .success(function (grps) {
                $scope.groups = grps;
                console.log($scope.groups);
            })
            .error(function (error) {
                $scope.status = 'Unable to load Product data: ' + error.message;
                console.log($scope.status);
            });
    }
});

GroupsApp.factory('GroupsService', ['$http', function ($http) {

    var GroupsService = {};
    GroupsService.getGroups = function () {
        return $http.get('showproduct');
    };
    return GroupsService;
}]);



</script>

Angluar数据显示代码

  <?php 

                                $cat3 = DB::table('category')->get();   
                                foreach($cat3 as $tt3)
                                 {      
                    ?>                  

                <div class="side-body padding-top" id="<?php echo ucfirst($tt3->id); ?>"><div ></div>
                    <h3 style="margin-top:0px; margin-bottom:0px;"><?php echo ucfirst($tt3->name); ?></h3>
                    <div class="row">
                       <div class="content2 mCustomScrollbar">

                              <div ng-if='r.category == <?php echo $tt3->id; ?>' ng-repeat = "r in groups | filter : searchGroups">
                                <div  class="col-sm-12 pad0" style="margin-bottom:1px; margin-top:1px; padding-right:15px; ">

                                    <div class="col-xs-2">
                                        <a href="#"><img class="img-responsive" src="@{{r.photo}}" alt=""></a>
                                    </div>
                                    <div class="col-xs-6 pad0" style="padding-left:10px;">
                                        <span class="tab pad0"> @{{r.name }}</span>
                                    </div>
                                    <div class="col-xs-1" ng-if='r.type == 1'>
                                        <img src="img/veg.jpg">
                                    </div>
                                    <div class="col-xs-1" ng-if='r.type == 2'>
                                        <img src="img/nonveg.jpg">
                                    </div>
                                    <div class="col-xs-2 pad0" style="padding-top:5px;">
                                        <span>Rs. @{{r.price}}</span>
                                    </div>

                                    <div class="col-xs-1"   ng-if='r.popup == 1' >
                                        <a class="btn btn-primary btn-sm btn-sm1" href="#"  data-id="@{{r.id}},@{{r.name}},@{{r.description}},@{{r.price}}"  style="margin-top:0px;">
                                        <i class="glyphicon glyphicon-plus"></i></a>
                                    </div>  

                                    <div class="col-xs-1"  ng-if='r.popup == 0' >
                                        <a class="btn btn-sm btn-primary btn-sm2" href="#" data-toggle="modal" data-target="#"  data-id="@{{r.id}}"  style="margin-top:0px;">
                                        <i class="glyphicon glyphicon-plus"></i></a>
                                    </div>
                              </div>
                              </div>

                              </div>
                              </div>

               </div> 

                    <?php
                    }
                    ?> 

但是当我没有在URL中传递ID时,我必须在URL中使用ID。请帮助解决问题。

0 个答案:

没有答案