snapjay / ngCart

Really simple shopping cart for AngularJS
http://ngcart.snapjay.com
380 stars 236 forks source link

ngcart directive #90

Open kostalihas opened 7 years ago

kostalihas commented 7 years ago

I create a new directive and passe the same content of ngcartCart directive and just change the template url because I need another form html for my cart, I dont know why I get nothing displayed.

GaboDot commented 7 years ago

Hi! I also created a custom directive as follows:

.directive('ngcartTotal', [function(){
        return {
            restrict : 'E',
            controller : 'CartController',
            scope: {},
            templateUrl: function(element, attrs) {
                if ( typeof attrs.templateUrl == 'undefined' ) {
                    return 'assets/js/template_cart/ngCart/cartTotal.html';
                } else {
                    return attrs.templateUrl;
                }
            },
            link:function(scope, element, attrs){

            }
        };
    }])

And then just call it using <ngcart-total></ngcart-total> Hope this helps!

kostalihas commented 7 years ago

yes it's a good idea ,another way I found it is to create a template.html and call it inside any directive using the attribute temlpate-url like bellow: <ngcart-addtocart template-url="/template/ngCart/cartpdj.html"></ngcart-addtocart>