Skip to content

Instantly share code, notes, and snippets.

@vilmosioo
Last active August 29, 2015 14:12
Show Gist options
  • Save vilmosioo/022a235709cac9dfe474 to your computer and use it in GitHub Desktop.
Save vilmosioo/022a235709cac9dfe474 to your computer and use it in GitHub Desktop.
ngIf in Angular 1.3
'use strict';
angular.module('myApp', [])
.directive('myDirective', function(){
return {
restrict: 'E',
template: '<div ng-if="isVisible"></div>',
scope: true,
controller: function(){
$scope.isVisible = false;
}
};
});
'use strict';
describe('myDirective test', function(){
var html = '<my-directive></my-directive>', scope;
beforeEach(module('myApp'));
beforeEach(inject(function($rootScope, $compile){
var element = angular.element(html);
$compile(element)($rootScope);
$rootScope.$digest();
scope = element.scope(); // this will break in angular 1.3
}));
it('should initialise scope', function(){
expect(scope.isVisible).toBeFalse();
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment