Are ion-header-bar and ion-content different scope?


#1

I’ve been working on solving the problem of the code at http://play.ionic.io/app/b2ece31d7dba

If I press the ADD2 button in the modal window, the error “undefined is not an object (evaluating ‘u.player_name’)” is shown. After some investigation, the code work successfully when I put the ADD1 button in the ion-content. From the result, I suppose ion-header-bar and ion-content are different scope but they are in the same ng-controller.

I want to place the button in ion-header-bar, and I want to pass the value of ng-model in the ion-content to createPlayer(). Any advice would be appreciated.


#2

Maybe a bit lat but for all other’s searching for a Solution.

The Problem is that ion-content has his own scope you can get around of this by using $parent:

<ion-content class="dark-bg padding has-header">
   <input type="text" ng-model="$parent.someVar" />
</ion-content>
<button class="button" ng-click="clickMe()">Click</button>
{{someVar}}