Use bindings instead of directly referencing the DOM attribute:
angular.module('example').component('exampleComponent', { bindings: { sortable: '<' }, controller: function() { var vm = this; var isSortable = vm.sortable; }, templateUrl: 'your-template.html' });
Template:
<example-component sortable="true"></example-component>
Using a one-way binding (indicated by "<"), the value of the "sortable" variable in the controller instance (named vm for the view model here) will be the boolean true if it is set, as shown in the example. If your sortable attribute currently contains a string in your template, a “@” binding may be the appropriate choice. The vm.sortable value will be a string (or undefined if the attribute is not defined in the component markup) in this case.
Checking for a simple sort attribute works as follows:
bindings: { sortable: '@' }
source share