Skip to content

Commit

Permalink
fix(ionContent): fix scoping with ngController
Browse files Browse the repository at this point in the history
Fixes #1155
  • Loading branch information
ajoslin committed Apr 21, 2014
1 parent 3c8f7bd commit 6abce8f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions js/angular/directive/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ function($timeout, $controller, $ionicBind) {
restrict: 'E',
require: '^?ionNavView',
scope: true,
priority: 800,
compile: function(element, attr) {
var innerElement;

Expand Down
8 changes: 7 additions & 1 deletion test/unit/angular/directive/content.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand All @@ -125,10 +125,16 @@ describe('Ionic Content Directive scoping', function() {
it('should have same scope as content', inject(function($compile, $rootScope) {
var element = $compile('<ion-content ng-controller="ContentTestCtrl">' +
'<form name="myForm"></form>' +
'<input ng-model="foo">' +
'</ion-content>')($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');
}));
});

0 comments on commit 6abce8f

Please sign in to comment.