angular-route-segment icon indicating copy to clipboard operation
angular-route-segment copied to clipboard

The directive link function be called twice

Open ZheFeng opened this issue 12 years ago • 3 comments

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.

ZheFeng avatar Sep 11 '13 02:09 ZheFeng

Did you find a solution ? I have exactly the same problem ... Thanks

maxime1992 avatar Mar 12 '15 11:03 maxime1992

@maxime1992 Yes, I'm using UI-ROUTER: https://github.com/angular-ui/ui-router

It's a very good and power angular router.

ZheFeng avatar Mar 13 '15 00:03 ZheFeng

Hitting the same issue. Anyone any idea??

yasar avatar Sep 05 '15 13:09 yasar