Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

什么是 AngularJS?


Angular

AngularJS 允许您使用称为指令的 HTML 属性来扩展 HTML。

AngularJS 指令为 HTML 应用程序提供功能

AngularJS 提供内置指令和用户定义指令。


AngularJS 指令

AngularJS 使用双大括号 {{ }} 作为数据的占位符。

AngularJS 指令是带有前缀 ng- 的 HTML 属性。

ng-app 指令初始化 AngularJS 应用程序。

ng-init 指令初始化应用程序数据。

示例

<div ng-app="" ng-init="message='Hello AngularJS!'">
  <h1>{{ message }}</h1>
</div>

自己尝试 »


ng-model 指令

ng-model 指令将 HTML 元素的值绑定到应用程序数据。

示例

<div ng-app="" ng-init="firstName='John'">

<p>姓名: <input type="text" ng-model="firstName"></p>
<p>您写道: <b>{{firstName}}</b></p>

</div>
自己尝试 »

ng-bind 指令

ng-bind 指令将数据绑定到模型。

示例

<div ng-app="" ng-init="firstName='John'">

<p>姓名: <input type="text" ng-model="firstName"></p>
<p>您写道 <b ng-bind="firstName"></b></p>

</div>
自己尝试 »

完整的 AngularJS 教程

这只是一个简短的 AngularJS 描述。

要获取完整的 AngularJS 教程,请访问 W3Schools AngularJS 教程

要获取完整的 AngularJS 参考,请访问 W3Schools AngularJS 参考


×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
[email protected]

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
[email protected]

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2024 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.