                     $controller rule.controller, resolve
                 $element.html rule.template
                 $compile($element.contents()) @scope
+                if rule.parents.length is 1
+                    $element.on 'click', 'a', onClickLink
             destroy: ->
                 return if not @rule
+                if @rule.parents.length is 1
+                    $element.off 'click', 'a', onClickLink
                 @scope.$destroy()
                 @scope = null
                 @rule = null


.directive 'poiView', ['$injector', ($injector) ->
    $router = $injector.get '$router'
    $compile = $injector.get '$compile'
    $controller = $injector.get '$controller'

    restrict: 'A'
    link: (scope, $element) ->

                @param destroy {bool} if it is true, call .$destroy()
                ###
                if destroy
                    if @rule.parents.length is 1
                        $element.off 'click', 'a', onClickLink
                    @scope?.$destroy()
                else if @rule
                    if $router.oldState.name.indexOf("#{$router.state.name}.") is 0
