{"id":17458121,"url":"https://github.com/pocesar/angular-errorlookup","last_synced_at":"2025-03-21T03:33:35.905Z","repository":{"id":17625204,"uuid":"20429440","full_name":"pocesar/angular-errorlookup","owner":"pocesar","description":"Because AngularJS general error messages still suck. ngMessages can kiss my ass.","archived":false,"fork":false,"pushed_at":"2016-07-17T18:15:37.000Z","size":331,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-09-27T09:30:01.333Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://pocesar.github.io/angular-errorlookup","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pocesar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-06-03T04:17:21.000Z","updated_at":"2016-10-03T08:36:37.000Z","dependencies_parsed_at":"2022-08-04T20:15:11.575Z","dependency_job_id":null,"html_url":"https://github.com/pocesar/angular-errorlookup","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pocesar%2Fangular-errorlookup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pocesar%2Fangular-errorlookup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pocesar%2Fangular-errorlookup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pocesar%2Fangular-errorlookup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pocesar","download_url":"https://codeload.github.com/pocesar/angular-errorlookup/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244734070,"owners_count":20501014,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-18T03:54:58.060Z","updated_at":"2025-03-21T03:33:35.602Z","avatar_url":"https://github.com/pocesar.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/pocesar/angular-errorlookup.svg?branch=master)](https://travis-ci.org/pocesar/angular-errorlookup?branch=master)\n[![Coverage Status](https://coveralls.io/repos/pocesar/angular-errorlookup/badge.svg?branch=master\u0026service=github)](https://coveralls.io/github/pocesar/angular-errorlookup?branch=master)\n\nAngularJS ErrorLookup\n===================\n\nBecause AngularJS general error messages still suck. ngMessages can kiss my ass.\n\nTL;DR http://pocesar.github.io/angular-errorlookup\n\nMade for Angular 1.4+, made in sexy Typescript\n\n## Install\n\n```bash\n$ bower install angular-errorlookup\n```\n\nHas jQuery and lodash as dependencies\n\n## Motivation\n\nHow is it better than `ngMessage` / `ngMessages`? Or plain old `ng-switch-when` / `ng-if` directive and a bunch of divs?\n\nBecause you need to write the same boring HTML markup over and over, and you need to cluttering your scope and\ncontrollers with useless state error messages. Plus, you are usually stuck with `modelController.$error` /\n`myForm.myModel.$error.required` / `myForm.$error.required[0].$error` (srsly wtf) boolean states.\n\nIt's nearly impossible to `$setValidity` without a helper directive that has access to some sort of global state,\nsince the ngModel controllers and form controllers are only available inside directives that require them or tied\nto a controller / scope. It's even worse, when you have to return validation from the server after a socket/ajax\ncall and show it in your form / models, or after async validation.\n\nSo, are you tired of no way of assigning errors dynamically, bypassing them when necessary? Does your scope variables\nlook like a mess with state errors? How about show a simple plain string on a form or console without assigning it\nto a scope/controller variable?\n\nTake this _superb_ code for example:\n\n```html\n\u003cform name=\"userForm\"\u003e\n  \u003cdiv class=\"field\"\u003e\n    \u003clabel for=\"emailAddress\"\u003eEnter your email address:\u003c/label\u003e\n\n    \u003cinput type=\"email\"\n           name=\"emailAddress\"\n           ng-model=\"data.email\"\n           ng-minlength=\"5\"\n           ng-maxlength=\"30\"\n           required /\u003e\n\n    \u003cdiv ng-messages=\"userForm.emailAddress.$error\"\u003e\n      \u003cdiv ng-message=\"required\"\u003eYou left the field blank...\u003c/div\u003e\n      \u003cdiv ng-message=\"minlength\"\u003eYour field is too short\u003c/div\u003e\n      \u003cdiv ng-message=\"maxlength\"\u003eYour field is too long\u003c/div\u003e\n      \u003cdiv ng-message=\"email\"\u003eYour field has an invalid email address\u003c/div\u003e\n    \u003c/div\u003e\n  \u003c/div\u003e\n\u003c/form\u003e\n```\n\nNow multiply that for 20 fields! Awesome right?\n\n![NO NO NO NO! HELL NO!](https://i.imgur.com/9utgk.gif)\n\nThis doesn't tie you with a controller or directives, and it doesn't aim to provide you a validation\ninterface. (Use [angular-async-validator](https://github.com/pocesar/angular-async-validator) for that)\n\n**This module aims to provide a D.R.Y. service for your errors, watching your models for ERRORS only**\n\nIt's an application-wide error messages service with helper directives for the heavy lifting! ngMessages\ndoesn't offer you a way to programatically set errors (unless you create a directive that requires ngModel\nand ngMessages, and you do the bridge, aka, hot mess).\n\nYou can use ErrorLookup in your DOM in a declarative manner, in your controller(s), in your directive(s),\nin  services (biggest win!), it keeps all your error messages under complete control (along with access\nto the bound element, scope and attributes), and you can have them using translations as well.\n\nBest of all: interpolation and callbacks! Make your errors beautiful and meaningful with magic. No more\nuseless boring generic messages like \"Please fill this field\" for every 350 fields in your forms and\ncopy pasting divs all over the place or making a damn directive that adds them after each of your\ninputs, and the need to use `$compile`, and all of the haX, like appending divs to DOM without you\nwanting it to.\n\n## Usage\n\n### Provider and Service\n\nThe `ErrorLookup` provider and service is that holds all messages and instances, models and attributes from your elements so it can be the ultimate overlord of your errors (and messages, but mostly errors, since it checks the `$error` member of the `ngModelController` and `FormController`).\n\n```js\nangular\n.module('YourApp', ['ngErrorLookup'])\n.config(['ErrorLookupProvider', function(ErrorLookupProvider){\n\n  // ErrorLookupProvider allows you to remove/add/overwrite your messages before your controllers load\n  ErrorLookupProvider.add('creditcard', 'The provided credit card isn\\'t valid');\n\n  ErrorLookupProvider.add('cvv', 'The CVV {{ model.$viewValue }} isn\\'t valid for {{ scope.cardType }}');\n\n  ErrorLookupProvider.add('repeated', 'The value {{ value }} doesn\\'t match {{ models.fucker.model.$viewValue }}');\n\n}])\n.controller('MainCtrl',\n  ['$scope', 'ErrorLookup',\n  function($scope, ErrorLookup){\n\n    // ErrorLookup is the full blown service\n    ErrorLookup.messages.types.email({value: 'name'}); // name is not a valid email\n\n    // Everything in types are a function from \"$interpolate\"\n    // You can overwrite them by using:\n    ErrorLookup.messages.add('email', 'O email \"{{value}}\" não é válido');\n    ErrorLookup.messages.types.email({value: 'name'}); // O email \"name\" não é válido\n  }\n]);\n```\n\nEasily retrieve localized messages from the server:\n\n```js\nangular\n.module('YourApp', ['ngErrorLookup'])\n// just use the helper FFS\n// assuming your json structure is:\n\n/*\n  {\n     \"required\": \"Você precisa preencher este campo\",\n     \"email\": \"O email \\\"{{ value }}\\\" é inválido\",\n     \"blacklist\": \"O \u003cstrong\u003eemail\u003c/strong\u003e não é permitido\"\n  }\n */\n.run(['ErrorLookup', function(ErrorLookup){\n  // Load ALL the messages\n  ErrorLookup.messages.include('/error-messages.json').then(function(messages){\n    // changing messages change them internally before applying it\n    delete messages['required'];\n  });\n}]);\n```\n\n### Locals for usage in message strings\n\nBut that's only for adding and manually setting error messages, which isn't much different from\nadding stuff to your controllers. We want moar.\n\nThere are a couple of locals you can use in your string messages:\n\n##### `{{ $label }}`\n\nPretty name of the model, instead of displaying \"login.data.user.email\" to the user, display\n something like \"Your email\". On the directive, it's the value of `error-lookup-label`\n\n##### `{{ $model }}`\n\nThe ngModel itself with all the bells and whistles, unchanged. On the directive, it's the\nvalue of `ng-model`\n\n##### `{{ $form }}`\n\nThis will only be available if it's triggered using `error-lookup-form`.\n\n##### `{{ $name }}`\n\nThe $name is the assigned name using `error-lookup-name`, `name` or `ng-model` attributes.\n\n##### `{{ $attrs }}`\n\nThe $attrs from the current element with all the bells and whistles, unchanged\nYou can even add CSS classes to the element through here, omg messy spaghetti!\n\n##### `{{ $value }}`\n\nAlias for the current model `$viewValue`. If you want the `$modelValue` use `$model.$modelValue`.\n\n##### `{{ $scope }}`\n\nThe assigned scope. You may access your controller doing `$scope.yourcontroller` in here as well.\n\n##### `{{ $models }}`\n\nALL the models in the current group! Means you can reference other `ngModels`, how cool is that?\n\nSince it uses interpolation, you always need to run the curryed function returned\nfrom the `ErrorLookup.error()`, since it has no watches and doesn't use `$compile` (that\nwatch over expressions automatically):\n\n```js\nangular\n.module('YourApp', ['ngErrorLookup'])\n.controller('MainCtrl',\n  ['$scope', 'ErrorLookup',\n  function($scope, ErrorLookup) {\n\n    $scope.error = ErrorLookup.error('MainCtrl', 'user.email');\n    // this function changes the internal error array of the current model everytime it's called, plus it returns\n    // the current error collection! (that is, an array of objects) So it's a setter AND a getter\n    // \u003cdiv ng-repeat=\"error in error() track by error.message\"\u003e\u003c/div\u003e\n\n    // Get ALL the errors in a group and assign them to the scope\n    $scope.errors = ErrorLookup.errors('MainCtrl');\n    // $scope.errors.user\n    // $scope.errors.password\n    // $scope.errors.repeat\n    // $scope.errors.fullname\n    // $scope.errors.email\n    // \u003cdiv ng-repeat=\"error in errors.user() track by error.message\"\u003e\u003c/div\u003e\n\n    // plucking just a few members\n    $scope.errors = ErrorLookup.errors('MainCtrl', ['user','password']);\n    // $scope.errors.user()\n    // $scope.errors.password()\n\n    // or the controller-bound preferred way\n    this.error = ErrorLookup.error('group', 'full.qualified.modelname.as.written.in.ng-model');\n  }\n]);\n```\n\n`ErrorLookup.error(group, modelIdentifier, predefine)` return a function that has the following signature `function(extra)`.\nEffectively, you can trigger new errors without the error being present on the model, like when you return validation from the server, without using `model.$setValidity`.\n\n```js\n$http.post('/isValid', {type: 'email', email: $scope.email}).success(function(errors){\n  if (errors !== false) {\n    $scope.error(errors); // assuming errors = {'blacklist': true, 'required': true}\n    // will look for default blacklist and required messages\n\n    // if you assign an string, it will be shown instead of the predefined messages\n    $scope.error({\n      'blacklist': 'You failed to enter your email, {{ $value }} even make sense to you? You dirty spammer'\n    }); // $interpolates this on the fly, not healthy for performance, beware\n  }\n});\n```\n\nBut wait! You don't need to add an string that will be interpolated, you can use a function! ...Here be dragons...\n\n```js\nErrorLookup.messages.add('dynamic', function(model){\n  // model is the programmatically equivalent of the scope variables in your interpolated string above\n  // \"this\" context is the internal \"model\"\n  if (model.$group === 'login') {\n      return 'Login failed';\n  } else if (model.$group === 'another') {\n      return 'Some shit happened';\n  }\n  // You must return an string here. Interpolate if you want, ErrorLookup don't care\n  return 'You failed';\n});\n```\n\nSo let the clusterfuck ensue! Break ALL the conventions! Access ALL the models! Pass ALL elements to callbacks! Wreck ALL the declarative behavior!\n\n## API\n\n### Provider\n\n##### `ErrorLookupProvider.add(name: String, expr: String|Function, trustedContext:String)`\n\nQueue a message to be lazy initialized when the ErrorLookup service is instantiated for the first time.\n\n```js\nErrorLookupProvider.add('required','\u003cstrong\u003e{{ label }}\u003c/strong\u003e is awesome, you gotta fill it', 'html');\nErrorLookupProvider.add('hallelujah','praise almighty code');\n```\n\n##### `ErrorLookupProvider.remove(name: String)`\n\nRemove a message from the queue.\n\n```js\nErrorLookupProvider.remove('required');\n```\n\n### Service\n\n\n#### ErrorLookup.translate(message: string): Function;\n\nReturns the interpolated function, shortcut for `this.messages[message]`.\nThrows if not defined\n\n```js\nErrorLookup.translate('notrequired'); // throws\n```\n\n#### ErrorLookup.validity(group: string, name: string, defs: {}): QPromise\u003cErrors[]\u003e;\n\nCalls `$setValidity` in the underlaying ngModel manually. Does nothing for forms.\n\n```js\nErrorLookup.validity('group','name', {\n    required: false,\n    email: true\n}).then(function(errors){\n    // errors = array\n});\n```\n\n#### ErrorLookup.validate(group: string, name: string): QPromise\u003cErrors[]\u003e;\n\nCalls `$validate` in the underlaying ngModel manually. If it's a form, it calls `$validate()` in all\nthe children.\n\n```js\nErrorLookup.validate('group','name');\n// calls ngModel.$validate();\n```\n\n#### ErrorLookup.errors(group: string, pick?: string[], errorArrays: boolean = false, predefine: {}, helpers: boolean = true, reset: boolean = true): {};\n\nBread and butter, returns an object with all the error messages helpers for a group, or you can pick some manually\n\n#### ErrorLookup.reset(group: string, name: string, pick: string[]): QPromise\u003cErrors[]\u003e;\n\nReset forced errors set using `ErrorLookup.set()` function\n\n#### ErrorLookup.set(group: string, name: string, errors: {}, reset: boolean = true): QPromise\u003cErrors[]\u003e;\n\nSet programatically an error and return a promise with the updated errors array.\nResets the errors if you specify, sets the model to dirty, and the form to dirty, then forcefully set the errors without updating the `ngModel.$errors`.\nIt's a sticky but superficial error, that isn't attached to the ngModel itself.\nUsually good to show error forms that come from the server, or manually set errors on inputs without actually making them invalid.\n\n```js\nErrorLookup.set('group','name', {\n    registered: true, // use the default registered error\n    domain: 'Domain is invalid' // override the default message\n}, true);\n```\n\n#### ErrorLookup.get(group: string, name: string = '', helpers = false, predefined: boolean = false): IErrorHelper;\n\nReturn either the whole group, a model, or helpers to save some calls to `ErrorLookup.item`,\n`ErrorLookup.error`, `ErrorLookup.set`, `ErrorLookup.label`, etc\n\n```js\nvar group = ErrorLookup.get('group', 'helper', true);\n/*\nreturns\n{\n    item: groupHelperModel,\n    error: Function,\n    set: (error: any),\n    label: (item: string, name: string),\n    reset: (pick: string[]),\n    validity: (validity: any  = {}),\n    remove: ()\n}\n*/\n```\n\n##### ErrorLookup.label(group: string, name: string|{}, label: string = ''): this;\n\nSet a pretty name for a model, can set many labels at once if you pass an object to the name.\n\n```typescript\nErrorLookup.label('somegroup', 'login.data.name', 'Login user');\nErrorLookup.label('somegroup', {\n    'login.data.name': 'Login user',\n    'login.data.pass': 'Password'\n});\n```\n\n##### `ErrorLookup.error(group: String, name: String, predefine: Object)`\n\nReturns a function so you can control the error for that field. Executing the returning function\nreturns an array with the errors (or an empty array if none). The errors are kept internally between\ncalls per model.\n\n```js\n// fn is Function(Extra: Object|Boolean): Array\nvar fn = ErrorLookup.error('group','user');\nfn({'required':true});\n/* returns */\n[\n  {\n    type:'required',\n    message:'You must fill user',\n    label:'user',\n    name:'user',\n    item:Model\n  }\n]\n```\n\nYou can also bypass the current messages that are set for a particular model, making it unique for the same error type\n\n```js\n// fn is Function(Extra: Object|Boolean): Array\nvar fn = ErrorLookup.error('group','user',{'required':'User is sooo required, please fill me in'});\nfn({'required':true});\n/* returns */\n[\n  {\n    type:'required',\n    message:'User is sooo required, please fill me in',\n    label:'user',\n    name:'user',\n    item:Model\n  }\n]\n```\n\nAnd you can bypass the bypass!\n\n```js\n// fn is Function(Extra: Object|Boolean): Array\nvar fn = ErrorLookup.error('group','user',{'required':'User is sooo required, please fill me in'});\nfn({'required':'w00t'});\n/* returns */\n[\n  {\n    type:'required',\n    message:'w00t',\n    label:'user',\n    name:'user',\n    item:Model\n  }\n]\n```\n\n##### `ErrorLookup.errors(group: String, pick: string[], arrays: Boolean = false, predefine: Object = {})`\n\nReturns an object with all the error functions from above. If you define an array in pick, you can retrieve\nonly some members of the group.\n\n```js\nvar errors = ErrorLookup.errors('group',['user','email']); // returns {'user':ErrorGetterFunction,'email':ErrorGetterFunction}\nerrors.user(); // [{type:'required'...}]\n```\n\nsetting arrays to true returns the current errors array:\n\n```js\nvar errors = ErrorLookup.errors('group', ['user','email'], true); // returns {'user':Array,'email':Array}\nerrors.user; // [{type:'required'...}]\n// the ErrorLookup.error() must be called somewhere for this array to be filled\n```\n\nYou can override the default errors of a group:\n\n```js\nvar errors = ErrorLookup.errors('group', [], false, {'required':'w00b'}); // returns {'user':ErrorFunction,'email':ErrorFunction,'password':ErrorFunction}\nerrors.email({required: true}); // [{type:'required','message':'w00b'}]\nerrors.password({required: true}); // [{type:'required','message':'w00b'}]\n```\n\n##### `ErrorLookup.remove(group: String, name: String)`\n\nRemove the model from the errors pile\n\n```js\nErrorLookup.remove(scope.$id, 'user');\nErrorLookup.remove('whole group'); // warning, remove the entire group\n```\n\n##### `ErrorLookup.add(config: Object)`\n\nThis method is boring as hell. Long parameter list and you shouldn't need to call it manually if you use the\ndirectives. You need to always provide non-optional stuff everytime to the function or it breaks.\n\nThe config object is as following:\n\n* `config.scope`      : the current scope. [Not Optional]\n* `config.name`       : the name of the ng-model, or any internal name you want to use. it must exist in the given scope [Not Optional]\n* `config.el`         : assign a DOM element to the current model [Not optional]\n* `config.group`      : the group name [Not optional]\n* `config.controller` : the model itself ngModelController (or ngFormController if you add a form model to it) [Not Optional]\n* `config.isForm`     : is the current controller FormController?\n* `config.attrs`      : the $attrs of the element, you can pass an object too when not adding from inside a directive\n* `config.label`      : the label to give the error. Defaults to the name of the model. pretty name for your `login.data.user` as `Your username` for example\n* `config.parent`     : set another ErrorLookup model as parent (not controllers!)\n\n```js\n/* ... */\n.directive('blah', ['ErrorLookup', function(ErrorLookup){\n  return {\n    require:'ngModel',\n    link: function($scope, el, attr, ctrl){\n\n      ErrorLookup.add({\n        scope      : $scope,\n        group      : $scope.$id,\n        name       : attr.ngModel,\n        controller : ctrl,\n        el         : el\n      });\n    }\n  }\n}]);\n```\n\n##### `ErrorLookup.messages`\n\nKeeps your application wide messages in a repository\n\n##### `ErrorLookup.messages.add(name: String, expr: String|Function, trustedContext: String)`\n\nAdds a message. Accepts a function (callback!) or a interpolated string. If you set `trustedContext` to 'html'\nit will use the `$sce` service and accept safe HTML in your interpolated string.\n\n```js\nErrorLookup.messages.add('required', '\u003cspan class=\"well\"\u003eYou need to fill this field\u003c/span\u003e', 'html');\n```\n\nReturns the current `$interpolate`d string or the function you passed, you can call it right way.\n\n##### `ErrorLookup.messages.remove(name: String)`\n\nRemove a message from the service\n\n```js\nErrorLookup.messages.remove('required'); // all \"required\" error messages, will be silently skipped when this error is present on ngModel =(\n```\n\n##### `ErrorLookup.messages.include(url: String)`\n\nLoads a JSON representation of your messages.\nReturns a promise. If you modify the resulting value, you can modify the included messages\n\n```js\nErrorLookup.messages.include('/messages.json').then(function(messages){\n  delete messages['required'];\n});\n```\n\n### Directives\n\n#### `error-lookup`\n\nThe `error-lookup` directive will add any `ng-model` element to the bunch.\n\nBy default, `error-lookup` group elements by `scope.$parent.$id`, but you can set your\nown name using `error-lookup=\"othergroup\"` (it's preferable this way, so you can reuse in\nyour code and set errors from inside services and other directives)\n\nThe name of the model will be your `error-lookup-name`, then `name` attribute, then your `ng-model`,\nin this order.\n\n`error-lookup-label` can apply a nice name to your model, like `error-lookup-label=\"Your email\"`.\n\n```html\n\u003c!-- add this ngModel to our ErrorLookup service --\u003e\n\u003cinput\n  ng-model=\"model.email\"\n  error-lookup-label=\"your email\"\n  error-lookup=\"login.interface\"\n  error-lookup-name=\"email\"\n  type=\"email\"\n  required\n  \u003e\n\n\u003c!-- error-lookup-label changes the $label variable --\u003e\n\u003c!-- error-lookup-name overrides your ng-model and name attributes --\u003e\n\n\u003c!-- You can, inside your controller, now use\n     ErrorLookup.get('login.interface','email'), and\n     even have access to this element lol, breaking\n     conventions since 2014\n     --\u003e\n\n\u003c!-- Display some nasty errors to the user, only from\n     login.interface and email model --\u003e\n\n\u003col error-lookup-display=\"email\" error-lookup-group=\"login.interface\"\u003e\n  \u003cli\u003e{{ $latest.message }}\u003c/li\u003e \u003c!-- only the latest error in the stack --\u003e\n  \u003cli\u003e{{ $first.message }}\u003c/li\u003e \u003c!-- only the latest error in the stack --\u003e\n  \u003cli ng-bind-html=\"$firstHtml\"\u003e\u003c/li\u003e \u003c!-- only the latest error in the stack --\u003e\n  \u003cli ng-bind-html=\"$latestHtml\"\u003e\u003c/li\u003e \u003c!-- only the latest error in the stack --\u003e\n  \u003cli ng-repeat=\"error in $errors track by $index\"\u003e{{error.message}}\u003c/li\u003e \u003c!-- or show ALL the errors --\u003e\n  \u003c!-- you can even make your shit clickable --\u003e\n  \u003cli ng-repeat=\"error in $errors track by $index\" ng-click=\"myWorldController.click(error)\" ng-bind-html=\"error.message\"\u003e\u003c/li\u003e\n  \u003cli\u003eShit! {{ $errorCount }} errors!\u003c/li\u003e\n\u003c/ol\u003e\n```\n\n#### `error-lookup-form`\n\nThis one is for forms, they keep all their children in sync (long missing from angular itself).\n\n```html\n\u003c!-- you can put it on forms, you can display errors for your form as a whole --\u003e\n\u003cform error-lookup-form=\"group\" name=\"fuck\"\u003e\n  \u003cinput ng-model=\"doh\" error-lookup=\"another-group\"\u003e\n  \u003cinput ng-model=\"srsly\" error-lookup=\"another-group\"\u003e\n  \u003cinput ng-model=\"input\" error-lookup=\"another-group\"\u003e\n  \u003cdiv\n      error-lookup-group=\"group\"\n      error-lookup-display=\"fuck\"\n      error-lookup-template=\"{filter:['form','only','errors'],exclude:['required']}\"\n      \u003e\u003c/div\u003e\n  \u003c!-- show all errors for all form models on one place --\u003e\n\u003c/form\u003e\n```\n\n#### `error-lookup-display`\n\nThe `error-lookup-display` is a shortcut to the `ErrorLookup.error()` function.\n\nThis directive exposes to the DOM the following scope variables:\n\n##### `$model: IErrorHelper;`\n\nThe ErrorLookup model\n\n##### `$errorCount: number;`\n\nCurrent error count\n\n##### `$first: IErrorMessage;`\n\nIs first error for that field, containing the fields described in\n[ErrorLookup.error()](#errorlookuperrorgroup-string-name-string-predefine-object)\n\n##### `$latest: IErrorMessage;`\n\nIs the top most error for that field, containing the fields described in\n[ErrorLookup.error()](#errorlookuperrorgroup-string-name-string-predefine-object)\n\n##### `$errors: any[];`\n\nCurrent cached array of errors\n\n##### `$hasChanged(): boolean;`\n\nIf the field has errors AND is `$dirty` AND has been `$touched`\n\nN.B: Since the scope isn't isolated, but a child scope, it inherits from the current scope it's in,\nmake sure to understand scope inheritance before you try your hax0rs in the code.\n\n##### `$latestHtml: angular.IAugmentedJQuery;`\n\nThe `$sce.trustAsHtml` version of `$latest`\n\n##### `$firstHtml: angular.IAugmentedJQuery;`\n\nThe `$sce.trustAsHtml` version of `$first`\n\n#### `error-lookup-template`\n\nThis directive creates a `ul` with a default limit of 1 item for errors.\nIt needs to be applied in the same element that has `error-lookup-display` on it.\n\n```html\n\u003cdiv\n    error-lookup-display=\"models.email\"\n    error-lookup-template=\"{filter: ['generic','someothererror', $variable], 'exclude':['required'], limit: 10}\"\n    \u003e\n  \u003c!-- setting `filter` will only show `generic`, 'someothererror' and something assigned to the scope $variable,\n      error messages --\u003e\n  \u003c!-- setting `limit` will limit the number of messages displayed at once --\u003e\n  \u003c!-- setting `exclude` won't show errors --\u003e\n  \u003c!-- all options are optional, they default to none and 1 respectively --\u003e\n\u003c/div\u003e\n```\n\n### Filter\n\nIt's used to filter error messages from a bunch of items in an array,\nused by the `error-lookup-template` directive:\n\n```html\n\u003cdiv error-lookup-display=\"name\"\u003e\n  \u003cdiv ng-repeat=\"error in $errors | errorMessages:$options\"\u003e{{ error }}\u003c/div\u003e\n\u003c/div\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpocesar%2Fangular-errorlookup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpocesar%2Fangular-errorlookup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpocesar%2Fangular-errorlookup/lists"}