Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

AngularJS HTML DOM


May 08, 2021 AngularJS


Table of contents


AngularJS HTML DOM

AngularJS provides instructions to bind app data to the properties of HTML DOM elements.

AngularJS has its own HTML property instructions.


ng-disabled instructions

The ng-disabled instruction sets the disabled property (input, select, or textarea) of the form input field.

If an expression in ng-disabled returns true, the form field is disabled

AngularJS instance

<div ng-app="">

<p>
<button ng-disabled="mySwitch">点我!</button>
</p>

<p>
<input type="checkbox" ng-model="mySwitch">按钮
</p>

</div>

Try it out . . .

Examples:

The ng-disabled instruction binds application data "mySwitch" to the disabled property of HTML.

The ng-model instruction binds "mySwitch" to the contents of the HTML input checkbox element (value).


ng-show instruction

The ng-show instruction hides or displays an HTML element.

AngularJS instance

<div ng-app="">

<p ng-show="true">我是可见的。</p>

<p ng-show="false">我是不可见的。</p>

</div>

Try it out . . .

You can hide and display HTML elements using an expression that is evaluated as true or false, such as ng-show" "hour" and "hour" and "lt; 12".

In the next chapter, there is another instance that hides an HTML element by clicking a button.

Related articles

HTML DOM element