I have created this directives: app.directive('city', ['$http', '$parse', function($http, $parse) { return { restrict: "C", link: function(scope, element, attrs) { scope.$watch(attrs.statetrigger, function() { state = $parse(attrs.statetrigger)(scope); country = $parse(attrs.countrytrigger)(scope); if (state !== undefined && country !== undefined) { $http.get(Routing.generate('cities') + '/' + country.iso_country + '/' + state.state).success(function(data) { if (data.message) { scope.message = data.message; } else { scope.cities = data.entities; } }).error(function(data, status, headers, config) { if (status == '500') { scope.message = "No hay conexión con el servidor."; } }); } }); } }; }]);
app.directive('courriercity', ['$http', '$parse', function($http, $parse) { return { restrict: "C", link: function(scope, element, attrs) { scope.$watch(attrs.statetrigger, function() { state = $parse(attrs.statetrigger)(scope); country = $parse(attrs.countrytrigger)(scope); console.log(state, country); if (state !== undefined && country !== undefined) { $http.get(Routing.generate('zoomcities') + '/' + country.iso_country + '/' + state.state).success(function(data) { if (data.message) { scope.message = data.message; } else { scope.zoomcities = data.entities; } }).error(function(data, status, headers, config) { if (status == '500') { scope.message = "No hay conexión con el servidor."; } }); } }); } }; }]); In my HTML code I have this elements: <select class="city" ng-model = "city.standard_address" ng-disabled = "!cities" ng-options = "city.name for city in cities" countryTrigger= "country.standard_address" stateTrigger = "state.standard_address"> <option value="">{{ "Select city" | trans }}</option> </select> <select class="courriercity" ng-model = "courrierCity.courrier_address" ng-disabled = "!zoomcities" ng-options = "city.name for city in zoomcities" countryTrigger= "courrierCountry.courrier_address" stateTrigger = "courrierState.courrier_address"> <option value="">{{ "Select city" | trans }}</option> </select> If I change the select with class "courriercity" the directive called is "city" always, why is that behavior? What is wrong in my code? -- 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 angular+unsubscr...@googlegroups.com. To post to this group, send email to angular@googlegroups.com. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.