asp.net mvc - undifined error of $scope variable in angularjs -
i developing ecommerce website asp.net mvc angularjs. getting issue $scope in 1 of page.i define $scope.items array in controller , trying fetch values in array cookies. here code
app.controller('checkoutcontroller', ['$scope', 'productservice', '$cookies', '$cookiestore', '$location', 'sharedservice', '$rootscope', 'customerservice', function ($scope, productservice, $cookies, $cookiestore, $location, sharedservice, $rootscope, customerservice) { $scope.items = []; $scope.customer = {}; $scope.customer.firstname = ""; $scope.customer.lastname = ""; $scope.customer.email = ""; $scope.customer.password = ""; $scope.customer.cpassword = ""; $scope.customer.address1 = ""; $scope.customer.address2 = ""; $scope.customer.zipcode = ""; $scope.customer.country = ""; $scope.customer.state = ""; $scope.customer.city = ""; $scope.customer.mobileno = ""; $scope.logdetails = {}; $scope.logdetails.logemail = ""; $scope.logdetails.logpassword = ""; $scope.customer.roleid = 1; $scope.items = $cookies.stylestorecart; }
it gives me error $scope.items not defined. defined
experts please tell me m going wrong?
here url of live website. please try checkout , see error in console on checkout page.
http://stylesstore.com/home/products
here way inserting data cookies in application in product page
var item = new cartitem(picture1, productname, unitprice); $scope.items.push(item); $cookies.stylestorecart = $scope.items $scope.itemcount = $scope.itemcount + 1
and in checkout page getting cookies values this
$scope.items = $cookies.stylestorecart;
this because items
assigned undefined
before access it.
in first line of code, initialize items
array, $cookiestore.get('stylestorecart')
undefined
, $scope.items
became undefined
after assignment.
update
home
page stores stylestorecart
in cookies successfully, if take @ cookie item using developer tool (in chrome, it's chrome://settings/cookies), you'll see cookie's path /home
. navigate http://stylesstore.com/cart/checkout
, path /cart
, that's maybe can't stylestorecart
cookies.
a proper solution is, store cookies below
$cookies.put('stylestorecart', value, {path: "/"});
Comments
Post a Comment