phpangularjsx-cart

How to implement angularjs in x-cart


Currently, I am working on x-cart and as you guys know x-cart is working on smarty template engine. Now my client wants angularjs in x-cart. Have tried so many things but unable to implement it. Have surfed on google but I also didn't get anyway. Can you guys please suggest me something?

I have to serve question.

  1. Is implementing angular js in x-cart is a good idea?
  2. Is it possible?
  3. If it is possible then how can we implement it?
  4. Does it affect other functionality of x-cart?

Please help me in it.

Thank you, guys.


Solution

  • okay, i got an answer. You can not implement angularjs directly as you are implementing in other websites. so here are the answers of your questions.

    1. Is implementing angular js in x-cart is a good idea? : it depends on what you actually want to do with it? as you wants angularjs to load page faster, first you may check and try this article. to increase performance . if your demands can be completed from here. you don't need angularjs.

    2. Is it possible?: Yes, it is possible. but you can't complete entire angularjs circle like a request to ng-route and get data back.

    3. If it is possible then how can we implement it?: all you have to do is include angular's js file and then create one script and get data in angular scope which are coming from php.

      for example: there is a product list page, data of products will come as products variable. so create a script in products_t page and get product data in angular scope. give ng-app in HTML from home.tpl file. here i am taking ProductsController.

    angular.module('myApp', []).controller('ProductsController', ['$scope', function($scope){ $scope.products = {$products};
    }]);

    Now define productlist main div as Products controller and process further angularjs operations.

    1. Does it affect other functionality of x-cart?: If you will follow this structure, it will not affect any x-cart module. just define all values properly.

    Suggestion: still if your demands are fulfilling from above link. don't try to implement angularjs.