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

ng-messages not showing inside $mdDialog #8037

@LQkkeN

Description

@LQkkeN

CodePen Demo

In the following small example, validation works (red lines appear and disappear based on input), but the ng-message do not display.

<form name="addUnitForm" ng-submit="addUnit(unit.name)">
    <md-input-container>
        <label>Name</label>
        <input name="name" type="text" ng-required="true" ng-model="unit.name" minlength="1" />
        <div ng-messages="addUnitForm.name.$error">
            <div ng-message-exp="['required', 'minlength']">Error message</div>
        </div>
    </md-input-container>
    [...]
</form>

The same code works when not inside an $mdDialog directive, so my best guess is, the directive is messing things up. This is the code initializing the dialogue:

$scope.addUnit = function() {
    $mdDialog.show({
        templateUrl: 'templates/addUnit.html',
        parent: angular.element(document.body),
        scope: $scope,
        clickOutsideToClose: true,
        preserveScope: true,
        controller: function(scope) {
            [...]
        }
    });
}

Could it be related to my inheritance of the global $scope into the directive?

Metadata

Metadata

Assignees

No one assigned

    Labels

    P4: minorMinor issues. May not be fixed without community contributions.needs: investigationThe cause of this issue is not well understood and needs to be investigated by the team or community

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions