Hi all,

I created a directive with a isolated scope and in my template an 
ng-include.

angular.module('myApp').directive('myDirective', ['$http', '$routeParams', 
function($http, $routeParams) {
    var _type = '';
        return {
                    scope:{
                        myModel : '='
                    },
                    restrict: 'AEC',
                    replace: true,
                    template: '<ng-include src="template" 
ng-click="onclick()"/>',
                    link: function (scope, element, attrs) {
                        scope.onclick = function onclick(){
                            console.log(_type);
                     };

                        scope.$watch('myModel', function(myModel){
                            if(scope.myModel !== undefined){
                                _type = myModel.Type;
                                scope.onclick();
                            }
                        });
                    }   
                };
        }
    ]);



I would like to remove scope.$watch because if I have on my html page twice 
this directive my _type variable will be the same for directives.
myModel Object is empty during the first seconds, so How can I watch 
myModel and have different _type for each directive ?


Regards

-- 
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