This file contains hidden or 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
<input type="email" | |
ng-model='userEmail' | |
name='email' required | |
class="form-control" | |
custom-validator="disposable" | |
validate-functions='disposableMail'/> |
This file contains hidden or 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
$scope.duplicateMailRemoteCheck = function (email) { | |
return $timeout(function () { | |
return ['[email protected]', '[email protected]', '[email protected]'].indexOf(email) >= 0 ? false : true; | |
}, 2000); | |
} |
This file contains hidden or 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
$scope.disposableMail = function (email) { | |
if (!email) return true; | |
return email.indexOf('@mailinator.com') >= 0 ? false : true; | |
} |
This file contains hidden or 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
<div> | |
<small class="error" ng-repeat="message in errorMessages" ng-show= "!modelController.$pristine && $first" class="warning"> | |
{{message}} | |
</small> | |
</div> |
This file contains hidden or 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
<div data-validation-messages='' model-controller='form.email' | |
required-error="Email id is required." | |
email-error="Email is not in correct format." /> | |
</div> |
This file contains hidden or 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
<input type="email" ng-model="user.email" name="uEmail" required /><br/> | |
<div ng-show="form.uEmail.$dirty && form.uEmail.$invalid"> | |
<span ng-show="form.uEmail.$error.required">Tell us your email.</span> | |
<span ng-show="form.uEmail.$error.email">This is not a valid email.</span> | |
</div> |
This file contains hidden or 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
angular.module('validation',[]) | |
.directive('customValidator', [function () { | |
return { | |
restrict: 'A', | |
require: 'ngModel', | |
scope: { validateFunction: '&' }, | |
link: function (scope, elm, attr, ngModelCtrl) { | |
ngModelCtrl.$parsers.push(function (value) { | |
var result = scope.validateFunction({ 'value': value }); | |
if (result || result === false) { |
This file contains hidden or 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
app.factory(‘Items’,function($http) { | |
var items = []; | |
return { | |
list: function() { | |
var defer=$q.defer(); | |
if (items.length == 0) { // items array is empty so populate it and return list from server to controller | |
$http.get(‘/?items’).then(function(response) { | |
items = response.data.items; | |
defer.resolve(items); | |
}); |
This file contains hidden or 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
angular.module('module1',[]); //declares a module. Note the second parameter which takes dependencies | |
angular.module('module1'); //gets a module with name module1, no second parameter |
This file contains hidden or 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
var element = document.getElementsById('id'); | |
var scope = angular.element(element).scope(); |