0

Laravel controller:

function printBarcode($id=null)
{
    print_r($id);
}

AngularJS controller:

$scope.select = function(data) {
    console.log(Object.keys(data.items));
    var id=[];

    for(var i=0; i<Object.keys(data.items).length; i++)
    {
        Object.keys(data.items)[i];
        id.push(Object.keys(data.items)[i]);
    }
    $http.get('/printbarcode/'+id).success(function (data) {
        console.log(data);
    }).
    error(function (data) {
        console.log(data);
    });
}`

Blade template:

<input type="checkbox" data-ng-model="barcodeData.items[<?php echo $items->item_code ;?>]"  value="{{$items->item_code}}" />

Routes:

Route::get('/printbarcode/{id}',array('as'=>'printBarcodes','uses'=>'BarcodeController@printBarcode'));

1 Answer 1

1

Whar do you wxpect with this: print_r($id);? It'a a string content in the response context. If you need a json response then:

function printBarcode($id=null)
{
    return json_encode([$id], true);
}
Sign up to request clarification or add additional context in comments.

3 Comments

its working.but i need to get that values on by one..now it came like this ` ["6211,6212"] 0 : "6211,6212" length : 1 `
i need these ids to generate view
i need to access this id values

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.