good morning I am new with angular, I have problems to send an object of angularjs to controller C #, I could send a string but at the time of wanting to send an object send me error someone some suggestion the code is the following
controlledrangularjs
ClaveTruper = "CTF-1/2";
Descripcion = "Cinta de teflon 1/2";
Precio ="$4"
PrecioEspecial ="$2"
PrecioFabrica ="$3"
Xml = obj2.Xml;
CapacidadGancho ="G30"
CodigoProducto = "12520";
var ntl = [ CodigoProducto, ClaveTruper, Descripcion, Precio, PrecioEspecial, PrecioFabrica, Xml, CapacidadGancho ];
// debugger;
ImprimirService.Impre(ntl)
.then(function (response) {
if (response.code = 100) {
// $scope.skuis = "";
$scope.impri = response.data.Result;
// $scope.skuis = Json.parse(angular.toJson(response.data.Result));
// console.log($scope.skuis);
$scope.impri = angular.fromJson($scope.impre);
//console.log($scope.skuis);
$scope.apply;
}
}, function (err) { });
return $scope.impri;
angular service
'use strict'
app.service('ImprimirService', ['$http', '$q', '$window', function ($http, $q, $window) {
this.Impre = function (etiqueta) {
var defered = $q.defer();
console.log("Entrando al Servicio Enviar datos para Imprimir")
$http({
method: 'POST',
url: 'Labels/Impre',
params: {
'etiqueta': JSON.stringify(etiqueta)
},
dataType:'json'
//params:{Itemcode:itemcode}
})
.then(function (response) {
defered.resolve(response);
},
function (err) {
defered.reject(err);
});
return defered.promise;
}
}]);
driver c #
[AllowAnonymous]
[HttpPost]
public JsonResult Impre(Imprimir etiqueta)
{
CentralPOSDataManager Code = new CentralPOSDataManager();
var result = Code.Imprimir(etiqueta);
return Json(result, JsonRequestBehavior.AllowGet);
}
public MethodResponse<Imprimir> Imprimir(Imprimir etiqueta)
{
MethodResponse<Imprimir> Result = new MethodResponse<Imprimir>() { Code = 100, Message = "Impresion Exitosa", Result = new Imprimir() };
try
{
var ClaveTruper = "CTF-1/2";
var Descripcion = "Cinta de teflon 1/2";
var Precio = "$4";
var PrecioEspecial = "$2";
var PrecioFabrica = "$3";
var Xml = "";//'<?xml version="1.0" encoding="utf-8"?><ThermalLabel Version="7.0" Width="60" Height="49" GapLength="3" MarkLength="0" OffsetLength="0" UnitType="Mm" LabelsPerRow="1" LabelsHorizontalGapLength="0" IsContinuous="False" PrintSpeed="" PrintMirror="False" CutAfterPrinting="False" ><Items><TextItem Name="Precio" Y="26" DataField="Precio" DataFieldFormatString="" CacheItemId="" Comments="" Tag="" Width="60" Height="15" Text="_x0024__x0020_1_x002C_495" Font="Arial,42,True,False,False,False,Point,,,False,90,,CP850" TextAlignment="Center" CultureName="en-US" /><TextItem Name="Descripcion" X="1" Y="6" DataField="Descripcion" DataFieldFormatString="" CacheItemId="" Comments="" Tag="" Width="57" Height="20" Text="Despachador_x0020_de_x0020_brocas_x0020_de_x0020_alta_x0020_velocidad_x0020_29_x0020_piezas" Font="Arial,16,Point,,,False,90,,CP850" TextAlignment="Center" CultureName="en-US" /><TextItem Name="CodigoProducto" X="1" Y="2" DataField="CodigoProducto" DataFieldFormatString="" CacheItemId="" Comments="" Tag="" Width="20" Height="4" Text="_x0031_4351" Font="Arial Black,9,Point,,,False,90,,CP850" TextAlignment="Justify" CultureName="en-US" /><TextItem Name="ClaveTruper" X="37.9686334474495" Y="2" DataField="ClaveTruper" DataFieldFormatString="" CacheItemId="" Comments="" Tag="" Width="20" Height="4" Text="DESP-BAV-29C" Font="Arial Black,9,Point,,,False,90,,CP850" TextAlignment="Right" CultureName="en-US" /><TextItem Name="PrecioEspecial" X="1" Y="44" DataField="PrecioEspecial" DataFieldFormatString="" CacheItemId="" Comments="" Tag="" Width="29" Height="4" Text="Especial_x0020_1_x002C_495" Font="Arial,9,Point,,,False,90,,CP850" CultureName="en-US" /><TextItem Name="PrecioFabrica" X="30" Y="44" DataField="PrecioFabrica" DataFieldFormatString="" CacheItemId="" Comments="" Tag="" Width="28" Height="4" Text="Fábrica_x0020_1_x002C_150" Font="Arial,9,Point,,,False,90,,CP850" TextAlignment="Right" CultureName="en-US" /><TextItem Name="CapacidadGancho" X="21.4641520797575" Y="1.95020953998517" DataField="CapacidadGancho" DataFieldFormatString="" CacheItemId="" Comments="" Tag="" Width="16.0243443647563" Height="4" Text="G8" Font="Arial Black,9,Point,,,False,90,,CP850" TextAlignment="Center" CultureName="en-US" /></Items></ThermalLabel >';
var CapacidadGancho = "G30";
var CodigoProducto = "12520";
// Arr ntl = etiqueta;//[ CodigoProducto, ClaveTruper, Descripcion, Precio, PrecioEspecial, PrecioFabrica, Xml, CapacidadGancho ];
var tl = Neodynamic.SDK.Printing.ThermalLabel.CreateFromXmlTemplate(etiqueta.Xml.ToString());
using (PrintJob pj = new PrintJob())
{
PrinterSettings myPrinter = new PrinterSettings();
myPrinter.ProgrammingLanguage = ProgrammingLanguage.EPL;
pj.PrinterSettings = myPrinter;
pj.Print(tl);
}
}
catch (Exception ex)
{
Result.Message = ex.Message + "METODO RESPONDE DE ETIQUETAS";
}
return Result;
}
I hope someone can give me a solution u.u thanks