From 6abce8f771f0e6eeae3e6e7d87f11bd3f2318dcc Mon Sep 17 00:00:00 2001 From: Andy Joslin Date: Mon, 21 Apr 2014 12:48:46 -0600 Subject: [PATCH] fix(ionContent): fix scoping with ngController Fixes #1155 --- js/angular/directive/content.js | 1 + test/unit/angular/directive/content.unit.js | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/js/angular/directive/content.js b/js/angular/directive/content.js index a4bd392183..ecb68f79f5 100644 --- a/js/angular/directive/content.js +++ b/js/angular/directive/content.js @@ -40,6 +40,7 @@ function($timeout, $controller, $ionicBind) { restrict: 'E', require: '^?ionNavView', scope: true, + priority: 800, compile: function(element, attr) { var innerElement; diff --git a/test/unit/angular/directive/content.unit.js b/test/unit/angular/directive/content.unit.js index 0d7b4bd202..5cb7bfd291 100644 --- a/test/unit/angular/directive/content.unit.js +++ b/test/unit/angular/directive/content.unit.js @@ -115,7 +115,7 @@ describe('Ionic Content directive', function() { }); }); -/* Tests #555 */ +/* Tests #555, #1155 */ describe('Ionic Content Directive scoping', function() { beforeEach(module('ionic', function($controllerProvider) { $controllerProvider.register('ContentTestCtrl', function($scope){ @@ -125,10 +125,16 @@ describe('Ionic Content Directive scoping', function() { it('should have same scope as content', inject(function($compile, $rootScope) { var element = $compile('' + '
' + + '' + '
')($rootScope.$new()); var contentScope = element.scope(); var ctrl = element.data('$ngControllerController'); expect(contentScope.myForm).toBeTruthy(); expect(ctrl.$scope.myForm).toBeTruthy(); + var input = angular.element(element[0].querySelector('input')); + input.val('bar'); + input.triggerHandler('input'); + expect(input.scope().foo).toBe('bar'); + expect(ctrl.$scope.foo).toBe('bar'); })); });