From 0fd5ab58703d30ad5949682fde96024b7d277e10 Mon Sep 17 00:00:00 2001 From: Caitlin Potter Date: Thu, 29 Jan 2015 12:13:40 -0500 Subject: [PATCH] fix($controller): throw better error when controller expression is bad Previously, the error was a JS runtime error when trying to access a property of `null`. But, it's a bit nicer to throw a real error and provide a description of how to fix it. Developer ergonomics and all that. Closes #10875 --- docs/content/error/$controller/ctrlfmt.ngdoc | 46 ++++++++++++++++++++ src/ng/controller.js | 9 +++- test/ng/controllerSpec.js | 43 +++++++++++++++++- 3 files changed, 96 insertions(+), 2 deletions(-) create mode 100644 docs/content/error/$controller/ctrlfmt.ngdoc diff --git a/docs/content/error/$controller/ctrlfmt.ngdoc b/docs/content/error/$controller/ctrlfmt.ngdoc new file mode 100644 index 000000000000..019598f7951e --- /dev/null +++ b/docs/content/error/$controller/ctrlfmt.ngdoc @@ -0,0 +1,46 @@ +@ngdoc error +@name $controller:ctrlfmt +@fullName Badly formed controller string +@description + +This error occurs when {@link ng.$controller $controller} service is called +with a string that does not match the supported controller string formats. + +Supported formats: + +1. `__name__` +2. `__name__ as __identifier__` + +N'either `__name__` or `__identifier__` may contain spaces. + +Example of incorrect usage that leads to this error: +```html + +