Improve this Doc

Error: $controller:ctrlfmt
Badly formed controller string

Badly formed controller string '{0}'. Must match `__name__ as __id__` or `__name__`.

Description

This error occurs when $controller service is called with a string that does not match the supported controller string formats.

Supported formats:

  1. __name__
  2. __name__ as __identifier__

Neither __name__ or __identifier__ may contain spaces.

Example of incorrect usage that leads to this error:

<!-- unclosed ng-controller attribute messes up the format -->
<div ng-controller="myController>

or

// does not match `__name__` or `__name__ as __identifier__`
var myCtrl = $controller("mY contRoller", { $scope: newScope });

or

directive("myDirective", function() {
  return {
    // does not match `__name__` or `__name__ as __identifier__`
    controller: "mY contRoller",
    link: function() {}
  };
});

To fix the examples above, ensure that the controller string matches the supported formats, and that any html attributes which are used as controller expressions are closed.

Please consult the $controller service api docs to learn more.