AngularJS中的表達式

AngularJS表達式 (AngularJS Expressions)

In AngularJS, expressions are solved to give a result. It outputs the result of the expression in the html element that called it. Expressions in AngularJS contain literals, constants, operators and variables with resolve to give desired output.

在AngularJS中, 表達式被求解以給出結果。 它在調用它的html元素中輸出表達式的結果。 AngularJS中的表達式包含文字,常量,運算符和變量,帶有可提供所需輸出的resolve。

Example: Angular Expression using Google CDN

示例:使用Google CDN的角度表達

<!DOCTYPE html>
<html ng-app>
<head>
<title>Angular Js</title>
<script src="https://ajax.googleapis.com/ajax/libs/AngularJS/1.7.2/angular.min.js">
</script>
</head>
<body>
<h2>Using Angular Js : Google CDN </h2>
<hr />
<div>
{{12+15}}
</div>
</body>
</html>

Output

輸出量

    27

Code explanation:

代碼說明:

The above code evaluates an expression in AngularJS. Using the ng-app in the html tag. This makes the whole page the owner of Angular i.e. code can be called from anywhere.

上面的代碼評估AngularJS中表達式 。 在html標簽中使用ng-app 。 這使得整個頁面成為Angular的所有者,即可以從任何地方調用代碼。

AngularJS中的表達式類型 (Types of expressions in AngularJS)

Expressions in AngularJS are based on the variables and literals used in the expressions,

AngularJS中的表達式基于表達式中使用的變量和文字,

1)AngularJS數字表達式 (1) AngularJS Number Expressions )

Number can also be used in expressions. Number expressions in angular are defined and used as in the below code,

數字也可以在表達式中使用。 定義和使用角度的數字表達式,如以下代碼所示,

Example:

例:

<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/AngularJS/1.6.9/angular.min.js"></script>
<body>
<div ng-app="">
<h1> Percentage Calculator </h1>
<form>
Marks Obtained :
<input type="number" ng-model="marksobtained"> Total Marks :
<input type="number" ng-model="totalmarks">
</form>
<h1>Percentage = {{(marksobtained*100)/totalmarks}}</h1>
</div>
<p>On putting the marks Obtained and total marks the percetage is given as output.</p>
</body>
</html>

Output

輸出量

Example 2 AngularJS

The above code takes input using form's input tag as angular variable and the does the calculations. Then prints the percentage to the <h1> tag.

上面的代碼使用表單的輸入標簽作為角度變量來接受輸入,然后進行計算。 然后將百分比打印到<h1>標簽。

2)AngularJS字符串表達式 (2) AngularJS String Expressions )

An expression in AngularJS can concatenate two strings to get an output string. String expressions in angular are defined and used as in the below code,

AngularJS中的表達式可以連接兩個字符串以獲取輸出字符串。 如下所示,定義并使用了angular字符串表達式,

Example:

例:

<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/AngularJS/1.6.9/angular.min.js"></script>
<body>
<div ng-app="">
<h1>Hello! </h1>
<form>
First Name :
<input type="text" ng-model="firstName"> Last Name :
<input type="text" ng-model="lastName">
</form>
<h1>Hello = {{firstName + lastName }} !</h1>
</div>
<p>On putting the marks Obtained and total marks the percetage is given as output.</p>
</body>
</html>

Output

輸出量

Example 3 AngularJS

3)AngularJS數組表達式 (3) AngularJS array Expressions)

An expression in AngularJS can operate on arrays also. Array expressions in angular are defined and used as in the below code,

AngularJS中的表達式也可以對數組進行操作。 按以下代碼定義和使用角度數組表達式:

Example:

例:

<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/AngularJS/1.6.9/angular.min.js"></script>
<body>
<div ng-app="" ng-init="array = [10, 20, 30, 40, 50] ">
<p>The third result is {{ array[1] }}</p>
</div>
</body>
</html>

Output

輸出量

Example 4 AngularJS

翻譯自: https://www.includehelp.com/angular-js/expressions-in-angularjs.aspx

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/377433.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/377433.shtml
英文地址,請注明出處:http://en.pswp.cn/news/377433.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

學習總結:機器學習(一)

有監督學習&#xff08;Supervised Learning&#xff09;所謂有監督學習&#xff0c;是區別于無監督學習而言的。其過程如下&#xff1a;給定一系列樣本&#xff0c;樣本是由一系列特征值和輸出值組成。比如&#xff0c;某個地方的商品房&#xff0c;包括房子大小、房間數、距離…

Silverlight讀取與設置Cookies

Silverlight讀取與設置Cookies 設置Cookie DateTime expire DateTime.UtcNow TimeSpan.FromDays(30);string cookie string.Formate("{0}{1},expires{2}",key,value,expire)HtmlPage.SetProperty("cookie",cookie);讀取Cookie 由于讀取到的Cookie是一個…

WPS雙欄格式下插入單欄圖片

以一個我認識的西工大博士大佬的一篇SCI為例&#xff0c;期刊是雙欄&#xff0c;圖片過大&#xff0c;需要單欄進行展示&#xff0c;效果圖如下&#xff1a; 一、雙欄內容 二、插入單欄圖像 隨便敲幾個字&#xff0c;選中&#xff0c; 頁面布局----分欄---一欄 這行字就會…

JavaScript中的數組

Here we are discussing one of the most useful data structure, Array. 在這里&#xff0c;我們討論最有用的數據結構之一Array 。 By conventional definition of arrays, "Arrays are the homogeneous collection of data types. But in JS, Arrays simply are the c…

【C++基礎】異常處理機制概要

目錄C的異常處理方法知識要點踹扔抓的代碼塊示例兩種處理被0除的方法異常處理機制的優點其他語言中的異常處理C函數異常聲明C的異常處理方法知識要點 理解“踹扔抓”三部曲的結構&#xff0c;尤其是catch是怎么匹配異常的。 知道C標準庫中的異常類都是從exception繼承下來的&am…

[轉載]Struts2 獲得Session和Request

轉自http://www.blogjava.net/lyyb2001/archive/2008/03/07/184593.html 在struts1中&#xff0c;獲得到系統的request或者session對象非常方便&#xff0c;都是按照形參傳遞的&#xff0c;但是在struts2中&#xff0c;request和session都被隱藏了struts提供兩種方式訪問sessio…

WPS根據章節編號依次排序

第Ⅲ章節有四小部分&#xff0c;分別為A、B、C、D 第Ⅳ章節要重新開始編號&#xff0c;從A開始 操作步驟&#xff1a; ①再D后面回車&#xff08;紅線位置回車&#xff09;&#xff0c;生成E ②把Ⅳ中待寫內容寫到E中 ③將E復制到Ⅳ下&#xff0c;這里需要注意D的換行也要復制…

【C++基礎】異常匹配與內建異常類

目錄異常匹配catch: 按異常類型匹配為何要使用異常類內建異常類標準庫中的異常基類標準庫中的異常類例1&#xff1a;vector下標訪問越界out_of_range異常例2&#xff1a;內存分配失敗bad_alloc異常例3&#xff1a;側向轉換失敗bad_cast異常類幾種情況&#xff0c;使用對應異常異…

scala 訪問修飾符_Scala中的訪問修飾符

scala 訪問修飾符Access modifiers are used in order to restrict the usage of a member function to a class or a package. Using access modifiers data hiding takes place which is a very important concept of OOPs. 訪問修飾符用于將成員函數的使用限制為類或包。 使…

小試---EF5.0入門實例1

現在做個小練習吧~~~ 第一步&#xff1a;首先新建一個數據庫名字為Test;數據庫里面只有一個表UserTable 腳本為&#xff1a; USE [master] GO /****** 對象: Database [Test] 腳本日期: 12/15/2013 18:51:54 ******/ CREATE DATABASE [Test] ON PRIMARY ( NAME NTest, F…

iScroll4 禁止select等頁面元素默認事件的解決方法 轉

iScroll4 禁止select等頁面元素默認事件的解決方法起因在于onBeforeScrollStart : function(e){ e.preventDefault(); },這一行&#xff0c;iSroll禁止了事件的默認行為&#xff0c;導致select&#xff0c;option&#xff0c;textarea等元素無法點擊。解決方法也很簡單&#xf…

C++中比較兩個浮點數是否相等

來源&#xff1a; https://stackoverflow.com/a/37686/3242645 代碼&#xff1a; #include <cmath> #include <limits> bool AreSame(double a, double b) {return std::fabs(a - b) < std::numeric_limits<double>::epsilon(); }

MPEG的完整形式是什么?

MPEG&#xff1a;運動圖像專家組 (MPEG: Moving Picture Experts Group) MPEG is an abbreviation of Moving Picture Experts Group. It is a working group of authorities that is founded to establish standards for audio and video compression and transmission. The a…

正則 去除html標記

//string regexstr "<[^>]*>"; //去除所有的標簽 //"<script[^>]*?>.*?</script>" //去除所有腳本&#xff0c;中間部分也刪除 // string regexstr "<img[^>]*>"; //去除圖片的正則 // string regexstr &…

自畫PopMenu彈出

BorderColor:TColor; //邊框顏色FillColor:TColor; //未選中填充顏色TextColor:TColor; //未選中字體顏色SelectTextColor:TColor; //選中字體顏色SelectFillColor:TColor; //選中填充顏色SideBuffer:Integer; //邊框寬度procedure TForm1.FormCreate(Sender: TObject); b…

安利一款倒計時插件---雨滴桌面

內容來自B站(搜索Rainmeter即可)&#xff0c;里面教程很多&#xff0c;因為視頻看的有點麻煩&#xff0c;故進行了整理 一、下載安裝包、解壓、安裝 免費下載連接&#xff0c;不需要積分 skin文件夾存放皮膚的一些配置文件&#xff0c;因為原本皮膚太low了 第二個是可執行文…

【C++基礎】自定義異常類與多重捕獲

目錄自定義異常類構建過程例&#xff1a;Vec3D類的數組下標越界的異常類捕獲多種無關異常不同的異常的捕獲捕獲派生異常異常處理的次序例子&#xff1a;多重捕獲異常類catch塊的參數類型可以不用引用類型嗎?自定義異常類 自定義異常類通常由exception或其后代類派生。這樣我們…

gprs 睡眠模式_GPRS的完整形式是什么?

gprs 睡眠模式GPRS&#xff1a;通用分組無線業務 (GPRS: General Packet Radio Service) GPRS is an abbreviation of General Packet Radio Service. It is a non-voice, high-level speed packet switching technology planned for GSM networks. On 2G and 3G cellular tran…

int main(int argc,char* argv[])講解

分類&#xff1a; 學習筆記2011-11-07 21:502354人閱讀評論(0)收藏舉報dos編譯器pathunixcommandc在最近學習中老是遇到 int main(int argc,char* argv[])&#xff0c;以為就是簡單的參數應用了&#xff0c;但是看代碼是沒能理解參數的具體傳遞過程&#xff0c;上網…

Maven實戰(七)——常用Maven插件介紹(上)

我們都知道Maven本質上是一個插件框架&#xff0c;它的核心并不執行任何具體的構建任務&#xff0c;所有這些任務都交給插件來完成&#xff0c;例如編譯源代碼是由maven-compiler-plugin完成的。進一步說&#xff0c;每個任務對應了一個插件目標&#xff08;goal&#xff09;&a…