Skip to content

Directive for Angular 1.x for dynamic element attributes

License

Notifications You must be signed in to change notification settings

argshook/ng-attr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ng-attr

<div ng-attr="{ 'attribute-name': scopeReference }"></div>

Directive for Angular 1.x for dynamic element attributes

Somewhat similar to ng-class but for attributes.

Given:

angular
    .module('myApp')
    .component('myComponent', {
        template: '<div ng-attr="{ \'special-attribute\': $ctrl.attrValue }"></div>',
        controller: function() {
            this.attrValue = 'Hello gurls';
        }
    });

will be compiled to

<div ng-attr="{ 'special-attribute': $ctrl.attrValue }" special-attribute="Hello gurls"></div>

Installation

  • npm i ng-attr --save
  • angular.module('yourModule', ['argshook.ngAttr'])

About

Directive for Angular 1.x for dynamic element attributes

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published