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.mzph.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…