Skip to content

onstyle attribute cannot be set with an AngularJS expression #31

@bertysentry

Description

@bertysentry
<toggle onstyle="{{'btn-success'}}" ng-model="$ctrl.myValue"></toggle>

triggers a $compile:nodomevents error.

while

<toggle offstyle="{{'btn-default'}}" ng-model="$ctrl.myValue"></toggle>

works without any issue.

This is because AngularJS prevents setting on* attributes (like onload, onclick, etc.) with an AngularJS expression.

Using x-onstyle or data-onstyle doesn't change the behavior.

The only fix to this would be to change the name of this attribute, like style-on. Any other idea?

PS: Behavior seen with AngularJS 1.7.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions