1

Getting issue with binding value while passing Event parameter from Template to Typescript Button click event.

enter image description here


See below object, its binding but it not reflecting same to the Typescript controller..

See here that value.. enter image description here

What it should be reason?

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) => {

        });
    }
}
9
  • it would be nice if you could share some of the code causing this issue.. as code not as screenshots. :) Commented Dec 31, 2016 at 17:01
  • pastebin.com/3SzHw94i Commented Dec 31, 2016 at 17:10
  • pastebin.com/4ZeVSEAk Commented Dec 31, 2016 at 17:12
  • you can use SO's editor to insert and format code. :) looking at the pastebin though I don't see how you actually link the controller with the view. Commented Dec 31, 2016 at 17:22
  • pastebin.com/2NeWnbSn see my email in pastebin. Commented Dec 31, 2016 at 17:25

1 Answer 1

1

ng-click shouldn't have {{}}(interpolation), do pass direct expression while will get evaluate.

Change

ng-click="vm.edit('{{order.orderID}}');"

to

ng-click="vm.edit(order.orderID);"
Sign up to request clarification or add additional context in comments.

2 Comments

i tried. it was getting object in controller not value.
it worked now in the direct object without single quote.

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.