Skip to content

Instantly share code, notes, and snippets.

@ekancepts
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ekancepts/d0574cbf38e03ac9d750 to your computer and use it in GitHub Desktop.
Save ekancepts/d0574cbf38e03ac9d750 to your computer and use it in GitHub Desktop.
Sending url params from angular to laravel

routes.js

           $routeProvider.when('/leads/:id/edit', {
                      templateUrl: '/leads/:id/edit',
                      controller: 'LeadEditController',
                      factory: ['LeadFactory'],
                      resolve: {
                          load: ['$q', '$rootScope',
                              function ($q, $rootScope) {
                                  var deferred = $q.defer();
                                  require(['app/controllers/LeadEditController',
                                      'app/factories/LeadFactory',
                                  ], function () {
                                      $rootScope.$apply(function () {
                                          deferred.resolve();
          
                                      });
                                  })} ]
                      }
                  });

LeadEditController

define(['app/app'], function (app) {
    'use strict';
    app.register.controller('LeadEditController', ['$scope','leadFactory','$route',
        function ($scope,leadFactory,$route) {
            var url_params = $route.current.params;
            console.log(url_params);
        }]);
});

** Larvel controller funuction code **

      public function edit($id)
      	{
              $lead = $this->contract->singleLeadData($id);
              $data = Response::json(array('status' => true,'lead' => $lead));
              return View::make( 'leads.edit' )->with('lead',$data);
      	}

** The error i am getting **/

SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for integer: \":id\"

I see that i am not able to pass id value to the server side code. How can i send the id value?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment