Advertisement
Guest User

Untitled

a guest
Aug 28th, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. angular.module('MyModule', [])
  2.  
  3. .directive('visible', function() {
  4.  
  5. return {
  6. restrict: 'A',
  7.  
  8. link: function(scope, element, attributes) {
  9. scope.$watch(attributes.visible, function(value){
  10. element.css('visibility', value ? 'visible' : 'hidden');
  11. });
  12. }
  13. };
  14. })
  15.  
  16. .controller('MyController', function($scope) {
  17. $scope.showButton = true;
  18. });
  19.  
  20. <div class="container">
  21. <button ng-click="isShown = !isShown" type="button">Toggle</button>
  22. </div>
  23.  
  24. <embed visible='showButton = !showButton' src="www.example.com/pdf2.pdf" width="500" height="500" type='application/pdf' id="myPdf2">
  25.  
  26. describe('Embed Control', function() {
  27. "use strict";
  28.  
  29. var spyEvent;
  30.  
  31. beforeEach(angular.mock.module('MyModule'));
  32.  
  33. it('Visibily hidden when toggled', function() {
  34.  
  35. spyEvent = spyOnEvent('toggleBtn', 'click')
  36. $('#toggleBtn').trigger("click");
  37.  
  38. expect('click')toHaveBeenTriggeredOn('#toggleBtn')
  39. expect(spyEvent).toHaveBeenTriggered();
  40. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement