*Thanks a lot Sander*

        $scope.keypress = function (id) {
            if (window.event.keyCode == 13) {

                $http.get("/api/CustomerService/GetProduct?id=" + 
id).success(function (data) {

                    // set ProductName, sell_price, stock Values
                    $scope.item.ProductName = data[0]["ProductName"];
                    $scope.item.sell_price = data[0]["sell_price"];
                    $scope.item.stock = data[0]["stock"];
                    $("#Quantity").focus();
                });
            }
        };

*it work's fine now, but please i still have 2 problem:*

*1. i do focus here with Jquery >> How can i do it with angular ?*

*2. i still get invoice in other pc with the item of another invoice that 
opened in other pc >> how cat i get empty invoice in any other pc ?*

*this is the image of invoice i work on in PC No1:*

<https://lh3.googleusercontent.com/-EVucOgWPwLA/VXtxYEnr07I/AAAAAAAABac/ECO00w7xW5Q/s1600/1.png>


*and when user open new invoice in his pc here got the same invoice data :*


<https://lh3.googleusercontent.com/-EVucOgWPwLA/VXtxYEnr07I/AAAAAAAABac/ECO00w7xW5Q/s1600/1.png>


*that is wrong - he must got an empty invoice ? so please how can i fix it 
?*


*Angular Code:*


        $scope.save = function () {
            $http.post("/api/customerService/Post", 
$scope.item).success(function (data) {
                $scope.orders.push(data);

                // Clear AutoComplete Text
                $("#Products").data("kendoAutoComplete").value("");

                if (window.event.keyCode == 13) {
                    $("#ProductID").focus();
                }

                $('#ProductID').prop('readonly', false);
            });
        };

        $http.get("/api/CustomerService/getDetails").success(function 
(data) {
            $scope.orders = data;
        });

*API Controller Code:*

    public class CustomerServiceController : ApiController
    {
        readonly Model1 db = new Model1();

        private static List<Order_Details_VM> listOfOrders;

        public CustomerServiceController()
        {
            if (listOfOrders == null)
            {
                listOfOrders = new List<Order_Details_VM>();
            }
        }

        public IHttpActionResult GetDetails()
        {
            return Ok(listOfOrders);
        }

        public IHttpActionResult Post(Order_Details_VM newOrderDetails)
        {
            if (newOrderDetails != null)
            {
                listOfOrders.Add(newOrderDetails);

                return Ok(newOrderDetails);
            }
            return null;
        }
    }

*View Code (this is section i got in each new Invoice):*

    <table class="table table-striped table-bordered" align="center" 
dir="rtl" ng-show="(orders).length">
        <tr>
            <th class="text-center" style="width:100px;">كود الصنف</th>
            <th class="text-center">إسم الصنف</th>
            <th class="text-center" style="width:150px;">الكمية</th>
            <th class="text-center" style="width:150px;">السعر</th>
            <th class="text-center" style="width:150px;">الإجمالى</th>
            <th style="width:150px;"></th>
        </tr>
        <tr ng-repeat="ord in orders">
            <td align="center" style="vertical-align:middle; 
font-weight:bold;">
                {{ord.ProductID}}
            </td>
            <td align="center" style="vertical-align:middle; 
font-weight:bold;">
                {{ord.ProductName}}
            </td>
            <td align="center" style="vertical-align:middle; 
font-weight:bold;">
                {{ ord.Quantity}}
            </td>
            <td align="center" style="vertical-align:middle; 
font-weight:bold;">
                {{ord.sell_price}}
            </td>
            <td class="text-center" style="vertical-align:middle; 
font-weight:bold;">
                {{ord.sell_price * ord.Quantity | currency}}
            </td>
            <td align="center" style="vertical-align:middle;">
                <input type="submit" name="submitbtn" value="x" class="btn 
btn-danger" ng-click="remove(ord.ProductID,$index)" 
style="font-weight:bold;" />
            </td>
        </tr>
    </table>

*Sorry for Long Description, but really don't know what i can do for that ?*

On Friday, June 12, 2015 at 5:11:57 AM UTC+2, Sander Elias wrote:
>
>
> Which controller where?
> it is better to make sure you always have an dot in your variable names 
> that are in your view. Meaninf, don't use $scope.price, but 
> $scoppe.item.price (which, in your view will be: item.price)
>
> Regards
> Sander
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to