Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use angularJS

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

Editor to share with you how to use angularJS, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's learn about it!

Event directive:

Ng-click/dblclick

Ng-mousedown/up

Ng-mouseenter/leave

Ng-mousemove/over/out

Ng-keydown/up/press

Ng-focus/blur

Ng-submit

Like ng-click, it binds events to dom

It should be noted that when using the event object, you need to pass $event in instructions such as ng-click, such as:

Aa

Form instruction

Ng-change

It's useful when the value changes.

Some tags with value value can be used only if they can be ng-model.

Ng-model must be used together.

Can do data verification.

Ng-disabled controls whether elements are available

Ng-readonly

Ng-checked

Controls whether checkbox is selected

Only set this to control whether it is selected or not only through data.

If you set ng-model, you can control the data through it.

The difference between disabled and readonly

Form elements can be disabled by setting the disabled or readonly attribute. After disabled is set, the user cannot use it, and the form will not submit the field, readonly

Only the user is disabled, that is, the user is inoperable, but the form is still submitted

Small cases of countdown rush to buy

$interval service is equivalent to setInterval and can automatically check dirty data.

To clear it, you need to assign a value and then $interval.cancel (timer)

Ng-show is displayed for true. False hiding

Ng-hide is hidden by true. False display

Ng-if is the same as ng-show, except that the node is not in the dom document if it is not displayed

Var app = angular.module ("myapp", [])

App.controller ("myController", function ($scope,$interval) {

$scope.num=1

$scope.canBuy = false

$scope.time = 5

Var timer = $interval (function () {

$scope.time--

If ($scope.time

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report