Encountering an issue with binding values when passing Event parameters from the Template to Typescript Button click event.
https://i.sstatic.net/SEnL6.png
Take a look at the object below, it is properly binding but not reflecting the same in the Typescript controller.
Check out this value.. https://i.sstatic.net/huyJj.png
What could be the reason for this?
Snippet of Code: Get Order template
<table class="table table-bordered">
<tr>
<td>ID </td>
<td>Name</td>
<td>Price</td>
<td>Action</td>
</tr>
<tr ng-repeat="order in vm.addNewOrderData track by $index">
<td><label>{{order.orderID}}</label> </td>
<td><label>{{order.orderName}}</label> </td>
<td><label>{{order.orderPrice}}</label> </td>
<td><label> <a href="javascript:void(0);" ng-model="editobj" ng-click="vm.edit('{{order.orderID}}');">Edit</a></label> </td>
</tr>
</table>
Below is GetOrderController.ts
class GetOrderController {
public vm: any;
private scope: any;
public addNewOrderData: any;
public http: any;
public location: any;
constructor($http: any, $scope: any, $location:any) {
this.scope = $scope;
this.scope.vm = this;
this.http = $http;
this.location = $location;
$http.get("/api/SampleApi/GetAllOrder").success(
(data, status) => {
if (data != "null") {
this.addNewOrderData = data;
}
}).error((data, status) => {
this.addNewOrderData = data;
});
}
edit = (id: any): void => {
debugger;
var order = { OrderID: id };
this.http.get("/api/SampleApi/GetOrderById",id
).success(
(data, status) => {
if (data != "null") {
this.location.path('/saveOrder?id=' + order);
}
else {
alert("No order id found!");
}
}).error((data, status) => {
});
}
}