alejandroiglesias / ng-attr

Directive for Angular 1.x for dynamic element attributes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

License:MIT License


Languages

Language:JavaScript 100.0%