The directive link function be called twice
When I'm using angular-route-segment, I have this route settings:
$routeSegmentProvider .when('/item/:id', 'item.edit')
$routeSegmentProvider.segment('item', { templateUrl: '/html/item.html', controller: 'item', dependencies: ['id'] }); $routeSegmentProvider.within('item').segment('edit', { templateUrl: '/html/edit.html', controller: 'edit' });
Then I have a directive like this: var myDirective = function() { return function(scope, element, attrs, controller) { console.log('myDirective'); }; };
this directive be called in edit.html
Then I found the directive function be called twice.
Is there any way to fix it? It's cause a problem when I add some event listener on element in the directive. If it's be call twice, means the event handler be added twice.
Did you find a solution ? I have exactly the same problem ... Thanks
@maxime1992 Yes, I'm using UI-ROUTER: https://github.com/angular-ui/ui-router
It's a very good and power angular router.
Hitting the same issue. Anyone any idea??