Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

bug(ngMessages): ngMessagesInclude crashes inside ngRepeat #11196

Closed
@adrianandreias

Description

@adrianandreias

Bug introduced in 1.4.0-beta.5: using ngMessagesInclude inside an ngRepeat (with ngForm - might be relevant) crashes with error:

Error: [$compile:ctreq] Controller 'ngMessages', required by directive 'ngMessage', can't be found!

See demo: http://plnkr.co/edit/9tEwZzf1q6qeUrL0rBxn?p=preview
Code is working fine in 1.3.14: http://plnkr.co/edit/yAuxsFGYymCj9fAAqTVw?p=preview

Crash does not occur if msgs.html is empty, it must have (any) content., i.e.:

<span ng-message="required">Field is required</span>
<span ng-message="number">Fill in a number</span>

I'll paste the demo code here, too:

<html>

<head>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0-beta.5/angular.js"></script>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0-beta.5/angular-messages.js"></script>
  <script src="script.js"></script>
</head>

<body>
  <div ng-app="myApp">
    <form name="myForm">
      <ul>


        <li ng-repeat="i in [1, 2, 3, 4]" ng-form="theForm">{{ i }}:
          <input type="number" ng-model="number" name="number">
          <div ng-messages="theForm.number.$error">
            <ng-messages-include src="msgs.html"></ng-messages-include>
          </div>
        </li>


      </ul>
    </form>
  </div>
</body>
</html>
angular.module('myApp', ['ngMessages'])
  .controller('MyCtrl', ['$scope', function($scope) {
  }]);

@matsko this is related to #10676 and matsko@d97733f

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions