0
votes

I'm just starting to learn Angular + Ionic, so pardon any potential ignorance :)

After, following the sample from Ionic's website I'm trying to expand upon it by assigning an ng-controller to my ion-nav-view. I'd like to use that so I can then listen for the $ionicView.enter on all the child views at one time, instead of having to do that separately inside of each child controller.

I add my controller like so:

<ion-nav-bar class="bar-positive">
  <ion-nav-back-button>
  </ion-nav-back-button>
</ion-nav-bar>

<ion-nav-view ng-controller="NavViewController"></ion-nav-view>

But it never actually executes the controller's constructor. If I move the assignment of the ng-controller up a level (e.g. the body element), it works fine. Is there any reason as to why that wouldn't work when assigned onto the ion-nav-view directly?

EDIT

Here's a codepen (trying to figure out why NavViewController isn't getting called):

http://codepen.io/anon/pen/WxYYkN

1
where are you setting ng-app? - Jorawar Singh
please share some more code - Jorawar Singh
From the tutorial, ng-app is set on the <html> tag. I added a codepen link to the desc. - chinabuffet

1 Answers

0
votes

Try this answer. Sorry that I didn't researched enough and misunderstood the article I read.