AngularJS Set Get and Remove Attribute Dynamically Form Element

In this Post We Will Explain About is AngularJS Set Get and Remove Attribute Dynamically Form Element With Example and Demo.Welcome on infinityknow.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to Set Attribute or Remove Attribute using AngularJSExample

In this post we will show you Best way to implement AngularJS remove HTML attributes Example, hear for angularjs – conditionally add an element attributewith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

READ :  C# swap two numbers without third variable

Angularjs read attribute value of an HTML elemnt

var myparm = angular.element( document.querySelector( '#live_divid' ) );
alert(myparm.attr('tempattrval'));

Angularjs set attribute value of an HTML element

var myparm = angular.element( document.querySelector( '#live_divid' ) );
myparm.attr('tempattrval',"attr val");

Angularjs remove attribute of an HTML element

var myparm = angular.element( document.querySelector( '#live_divid' ) );
myparm.dltAttribute('tempattrval');

Angularjs Set Attribute or Remove Attribute using AngularJS




<button>
  Read HTML Attribute value
</button>
<hr />
<button>
  Set HTML Attribute value
</button>
<hr />
<button>
  Remove HTML Attribute value
</button>
<hr />
<div id="live_divid">
  HTML Attribute DIV
</div>

function liveCtrl($scope) {
    $scope.readAttrval = function() {
     var myparm = angular.element( document.querySelector( '#live_divid' ) );
     alert(myparm.attr('tempattrval'));
    }
    $scope.setAttr = function() {
     var myparm = angular.element( document.querySelector( '#live_divid' ) );
     myparm.attr('tempattrval',"attr val");
     alert("HTML attribute set");
    }
    $scope.dltAttribute = function() {
     var myparm = angular.element( document.querySelector( '#live_divid' ) );
     myparm.dltAttribute('tempattrval');
     alert("HTML attribute removed");
    }
}

<a href="http://angular.min.js">http://angular.min.js</a>


Example

READ :  Angular Dynamically Delete Row from Table

I hope you have Got What is angularjs – conditionally add an element attribute And how it works.I would Like to have FeadBack From My Blog(infinityknow.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(infinityknow.com) Are Most Always Welcome.