Last active
August 29, 2015 14:12
-
-
Save vilmosioo/022a235709cac9dfe474 to your computer and use it in GitHub Desktop.
ngIf in Angular 1.3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
angular.module('myApp', []) | |
.directive('myDirective', function(){ | |
return { | |
restrict: 'E', | |
template: '<div ng-if="isVisible"></div>', | |
scope: true, | |
controller: function(){ | |
$scope.isVisible = false; | |
} | |
}; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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