Skip to content

Commit 6abce8f

Browse files
committed
fix(ionContent): fix scoping with ngController
Fixes #1155
1 parent 3c8f7bd commit 6abce8f

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

Diff for: js/angular/directive/content.js

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ function($timeout, $controller, $ionicBind) {
4040
restrict: 'E',
4141
require: '^?ionNavView',
4242
scope: true,
43+
priority: 800,
4344
compile: function(element, attr) {
4445
var innerElement;
4546

Diff for: test/unit/angular/directive/content.unit.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ describe('Ionic Content directive', function() {
115115
});
116116

117117
});
118-
/* Tests #555 */
118+
/* Tests #555, #1155 */
119119
describe('Ionic Content Directive scoping', function() {
120120
beforeEach(module('ionic', function($controllerProvider) {
121121
$controllerProvider.register('ContentTestCtrl', function($scope){
@@ -125,10 +125,16 @@ describe('Ionic Content Directive scoping', function() {
125125
it('should have same scope as content', inject(function($compile, $rootScope) {
126126
var element = $compile('<ion-content ng-controller="ContentTestCtrl">' +
127127
'<form name="myForm"></form>' +
128+
'<input ng-model="foo">' +
128129
'</ion-content>')($rootScope.$new());
129130
var contentScope = element.scope();
130131
var ctrl = element.data('$ngControllerController');
131132
expect(contentScope.myForm).toBeTruthy();
132133
expect(ctrl.$scope.myForm).toBeTruthy();
134+
var input = angular.element(element[0].querySelector('input'));
135+
input.val('bar');
136+
input.triggerHandler('input');
137+
expect(input.scope().foo).toBe('bar');
138+
expect(ctrl.$scope.foo).toBe('bar');
133139
}));
134140
});

0 commit comments

Comments
 (0)