2

I was working on an angular app (phonegap+ionic+angular), I had written a custom directive which registered an event listener for that element (which would activate iScroll for that element on load event). The directive was working fine when all the view was in index.html. I decided to refactor the code and intorduced nested views and routes using ui-router. Now the directive seems to be not functioning. I tried making a mock directive that would just console.log() and nothing happened. Am I missing something here?

Any kind of help or lead would be highly appreciated.

Thanks.

3
  • 1
    Most problems I have using nested directives come from losing the proper scope. Did you check that? Commented Jun 13, 2014 at 7:20
  • I have two controllers. One for the parent view and one for the nested view. Can you tell me (or point to some article) how to manage the scope between these two controllers? @MarioLevrero Commented Jun 17, 2014 at 5:21
  • 1
    Article: jimhoskins.com/2012/12/14/nested-scopes-in-angularjs.html In addition, I use Batarang extension for Chrome to have a clear view of the scopes : chrome.google.com/webstore/detail/angularjs-batarang/… Commented Jun 17, 2014 at 8:29

1 Answer 1

3

I have found the problem and the solution to my problem. I'm posting here so that others facing similar problems could benefit from it.

Turns out, since my directive did not run because it was executed before the sub view was loaded. So I solved the problem by just adding a scope.$watch("$viewContentLoaded") wrapper around my directive's codes and it started working.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, it's a good point, I have 20 uiview's in a single page, before using ui-route I was using ng-include and ng-switch and all of my directives where working well, but with ui route the model which provide from service by using $http.get is not provide data inside directive until using scope.$watch('scope-attr-name').

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.