AngularJS Set Get and Remove Attribute Dynamically Form Element

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 :  Angularjs Inline Edit example - AngularJs update and save table Row Examples

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 :  VueJs Methods and Event Handling Example

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.

Leave a Reply

Your email address will not be published. Required fields are marked *