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.

Update to Angular 1.4 breaks directives that manipulate ngOptions data #13145

Closed
@realityking

Description

@realityking

I think there's some subtle difference in the way scopes work between 1.3 and 1.4, but I couldn't find anything in the changelogs.

In 1.3 we use a directive like the following to add data to a select element. We don't put the entire element into the directive, as that breaks the for attribute, it's also not that easy to handle with ngModel.

module.directive('selectCountry', function () {
        return {
            restrict: 'A',
            scope: true,
            link: function ($scope, elem, attrs) {
                attrs.ngOptions = 'country.code as country.name for country in countryList | orderBy:"name"';
            },
            controller: function ($scope, countryList) {
                $scope.countryList = [];

                countryList.getList()
                    .then(function(result) {
                        $scope.countryList = result;
                    });
            }
        };
    })

Plunkr: http://embed.plnkr.co/COWqvLE14hFHnioHn9dP/preview

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions