The beast's angular Api learning, translating and understanding-Ngchange, ngchecked, Ngclick, Ngdblclick

Source: Internet
Author: User

ng API Learning for Beasts-Ngchange, Ngchecked, Ngclick, Ngdblclick

Ngchange

Executes the given expression when the user changes the input. The expression is executed immediately, and the JavaScript onchange event is performed differently only when the change of the triggering event ends.

Format: ng-change= "value"

Value: An expression.

Using code:

<div ng-app= "Demo" >

<div ng-controller= "Testctrl" >

<input ng-change= "FN ()" ng-model= "Inputvalue"/>

</div>

</div>

<script>

Angular.module ("Demo", [])

. Controller ("Testctrl", ["$scope", function ($scope) {

$scope. fn = function () {

Alert ($scope. Inputvalue);

};

}])

</script>

This instruction is to listen to the input value, when the value changes, you need to let me do what I do what the operation.

Ngchecked

The HTML specification does not allow the browser to keep the Boolean property, just like checked. (They exist as true, not present is false) if we convert a angular expression to such a property, the bound information disappears when the browser removes the property. The ngchecked directive solves the problem of checked this property. This supplemental instruction is not removed by the browser and provides a permanent and reliable place to store the binding information.

Format: ng-checked= "value"

Value: Expression result is a Boolean type

Using code:

<input type= "button" ng-click= "isChecked =!ischecked" value= "Toggle"/>

<input type= "checkbox" ng-checked= "isChecked"/>

Secretly, this command in the choice of configuration when it is very useful oh.

Ngclick

The Ngclick directive allows a specified expression to be executed when an element is clicked.

Format: ng-click= "value"

Value: An expression

Using code:

<input type= "button" value= "Add-count" ng-click= "count=count+1" ng-init= "count=0;"/>

{{count}}

Mouse click event, do not say more.

Ngdblclick

The Ngdblclick directive allows you to execute a specified expression on an DblClick event.

Format: ng-dblclick= "value"

Value: An expression

Using code:

<input type= "button" value= "Add-count" ng-dblclick= "count=count+1" ng-init= "count=0;"/>

{{count}}

Double-click the mouse event without explanation.

After summing up, early to bed and early to good health, the beast to sleep-. -You have to get up early to work tomorrow.

The beast's angular Api learning, translating and understanding-Ngchange, ngchecked, Ngclick, Ngdblclick

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.