Mastering Web Application
Building Your Own Directives Writing a button directive All the buttons in our application should be styled as a Bootstrap CSS b ...
Chapter 8 Let's look at how this directive could be implemented: myModule.directive('button', function() { return { restrict: 'E ...
Building Your Own Directives By putting the functionality in the compile function, it is only called once, and the button is sim ...
Chapter 8 Writing tests for the pagination directive The tests for this widget need to cover all the changes that can occur both ...
Building Your Own Directives expect($scope.currentPage).toBe(2); }); it('does not change the current page on "next" click if alr ...
Chapter 8 The template uses an array called pages and a number of helper functions, such as selectPage() and noNext(). These are ...
Building Your Own Directives While an isolated scope does not prototypically inherit from its parent, it can still access its pa ...
Chapter 8 A common mistake is to expect an interpolated object to be the object itself. Interpolation always returns a string. S ...
Building Your Own Directives This binding is equivalent to $parse the expression in the attribute and exposing the parsed expres ...
Chapter 8 }; scope.selectNext = function() { if ( !scope.noNext() ) { scope.selectPage(scope.currentPage+1); } }; } The link fun ...
Building Your Own Directives We create a spy to handle the call-back and then the it function gets called when we click on a new ...
Chapter 8 This custom model validator directive must integrate with ngModelController to provide a consistent validation experie ...
Building Your Own Directives Searching for parents for the controller If the directive, whose controller you require, can appear ...
Chapter 8 Writing custom validation directive tests The pattern for testing validation directives is to compile a form containin ...
Building Your Own Directives $scope.$digest(); expect(modelCtrl.$valid).toBeFalsy(); expect(modelCtrl.$viewValue).toBe(undefined ...
Chapter 8 Implementing a custom validation directive Now we have our tests in place, so we can implement the functionality of th ...
Building Your Own Directives In our Admin User Form, we would like to check whether the e-mail address that a user is entering h ...
Chapter 8 Writing tests for asynchronous validation We set up the test similar to the previous validation directive: beforeEach( ...
Building Your Own Directives $scope.$digest(); testInput.$setViewValue('
[email protected]
'); expect(Users.query).not.toHaveBeenCalle ...
Chapter 8 ngModelCtrl.$setValidity('uniqueEmail', false); } }); return viewValue; } }); } }; }]); We are only checking with the ...
«
8
9
10
11
12
13
14
15
16
17
»
Free download pdf