I’m working on 2 directives that get dynamically compiled (rather than in HTML) and need access to the active view in the DOM.
Unfortunately querySelector on [nav-view=“active”] isn’t reliable as the directive is compiled before the active/cached view stuff has been sorted out.
Additionally I have a view that can’t be cached, so its getting removed and appended so the view indexes change.
I have even tried using ionicHistory’s currentView().index however as I stated the indexes change so this isn’t reliable.
Never mind! a simple $timeout was good enough to let ionic finish doing its thing. If anyone is interest in the plugin check it out! Facebook style info/error banner. Just published to Bower!
another approach would be to do hang in the dom-node for the directive after the view is active and fully entered
or use the $ionicView.enter-Event in your directive and get the currentView after that
PS: add you directive to npm. it is more and more favorised than bower
@bengtler Cool i have to make it browserify compatible first but will do.
The reason I can’t use enter is because this is a service level directive meaning that it is only called via a service, rather than a directive you would place directly in HTML like the actionsheet. When you call $ionicContentBanner.show(…) , a new isolate scope is created, but even listening to enter on rootScope gave me inconsistent results for the active view if one or more disabled caching (due to the appending/removing views from DOM).
But I got it working now, so it’s all good! thanks!
The problem is that when I hard code these definitions it works, but when I want to put them in the dom with {{definitions}}
where I have in my page.ts this.definition = <defs..../defs>;
It doesn’t work. I presume that is because they arrive too late ? How to get them loaded before the text is called ?